"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
some tweaks for cmd_info
To:
gameoftrees@openbsd.org
Date:
Sat, 23 Jul 2022 18:25:18 +0200

Download raw body.

Thread
three small nits, no functional changes intended.

 - pack_fds is unused
 - the worktree is never closed
 - we can get away without the wpath, proc, exec and sendfd promises

The pledge promises can be safely removed because `got info' only looks
at the fileindex, it doesn't need to call the libexec helpers, nor tries
to create it AFAICS.  if called with zero paths it could also drop the
"rpath" promise too eventually.

There is no regress for info, but it seems to work fine (both as `got
info' and as `got info paths...')


P.S.: should `got info' print also the selected author?  to play with
the GOT_IGNORE_GITCONFIG env i've made `got info' to print the author,
that's why i noticed this nits, but maybe it could be useful to debug
the setup if `got info' would print also the selected author?

diff /home/op/w/got
commit - dd2ffb6aab71d23f9c6afaa547b597deed3f43ad
path + /home/op/w/got
blob - b9db7903341646a697d55d321ba5112732c7dd4a
file + got/got.c
--- got/got.c
+++ got/got.c
@@ -12990,7 +12990,6 @@ cmd_info(int argc, char *argv[])
 	struct got_pathlist_entry *pe;
 	char *uuidstr = NULL;
 	int ch, show_files = 0;
-	int *pack_fds = NULL;
 
 	TAILQ_INIT(&paths);
 
@@ -13016,10 +13015,6 @@ cmd_info(int argc, char *argv[])
 		goto done;
 	}
 
-	error = got_repo_pack_fds_open(&pack_fds);
-	if (error != NULL)
-		goto done;
-
 	error = got_worktree_open(&worktree, cwd);
 	if (error) {
 		if (error->code == GOT_ERR_NOT_WORKTREE)
@@ -13028,9 +13023,8 @@ cmd_info(int argc, char *argv[])
 	}
 
 #ifndef PROFILE
-	/* Remove "cpath" promise. */
-	if (pledge("stdio rpath wpath flock proc exec sendfd unveil",
-	    NULL) == -1)
+	/* Remove "wpath cpath proc exec sendfd" promises. */
+	if (pledge("stdio rpath flock unveil", NULL) == -1)
 		err(1, "pledge");
 #endif
 	error = apply_unveil(NULL, 0, got_worktree_get_root_path(worktree));
@@ -13087,12 +13081,8 @@ cmd_info(int argc, char *argv[])
 		}
 	}
 done:
-	if (pack_fds) {
-		const struct got_error *pack_err =
-		    got_repo_pack_fds_close(pack_fds);
-		if (error == NULL)
-			error = pack_err;
-	}
+	if (worktree)
+		got_worktree_close(worktree);
 	TAILQ_FOREACH(pe, &paths, entry)
 		free((char *)pe->path);
 	got_pathlist_free(&paths);