git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] repack.c: rename and unlink pack file if it exists

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 5, 2014, 20:10 UTC
Message-ID
<xmqqwqh92uds.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140205011632.GA3923@sigill.intra.peff.net>

... and this is the other half that is supposed to be only about renaming variables.

-- >8 --
From: Torsten Bögershausen <tboegi@web.de>
Date: Sun, 2 Feb 2014 16:09:56 +0100
Subject: [PATCH] repack.c: rename a few variables

Rename the variables to match what they are used for: fname for the final name of the new packfile, fname_old for the name of the existing one, and fname_tmp for the temporary name pack-objects created the new packfile in.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/repack.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/builtin/repack.c b/builtin/repack.c
index fe31577..3b01353 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -316,33 +316,33 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
 	/* Now the ones with the same name are out of the way... */
 	for_each_string_list_item(item, &names) {
 		for (ext = 0; ext < 2; ext++) {
-			char *fname, *fname_old;
+			char *fname, *fname_tmp;
 			struct stat statbuffer;
 			fname = mkpathdup("%s/pack-%s%s",
 					packdir, item->string, exts[ext]);
-			fname_old = mkpathdup("%s-%s%s",
+			fname_tmp = mkpathdup("%s-%s%s",
 					packtmp, item->string, exts[ext]);
-			if (!stat(fname_old, &statbuffer)) {
+			if (!stat(fname_tmp, &statbuffer)) {
 				statbuffer.st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
-				chmod(fname_old, statbuffer.st_mode);
+				chmod(fname_tmp, statbuffer.st_mode);
 			}
-			if (rename(fname_old, fname))
-				die_errno(_("renaming '%s' failed"), fname_old);
+			if (rename(fname_tmp, fname))
+				die_errno(_("renaming '%s' into '%s' failed"), fname_tmp, fname);
 			free(fname);
-			free(fname_old);
+			free(fname_tmp);
 		}
 	}
 
 	/* Remove the "old-" files */
 	for_each_string_list_item(item, &names) {
 		for (ext = 0; ext < 2; ext++) {
-			char *fname;
-			fname = mkpath("%s/old-%s%s",
+			char *fname_old;
+			fname_old = mkpath("%s/old-%s%s",
 					packdir,
 					item->string,
 					exts[ext]);
-			if (remove_path(fname))
-				warning(_("removing '%s' failed"), fname);
+			if (remove_path(fname_old))
+				warning(_("removing '%s' failed"), fname_old);
 		}
 	}
 
-- 
1.9-rc2-217-g24a8b2e
Previous: Torsten Bögershausen
Message 15 of 15 in “repack.c: rename and unlink pack file if it exists”
  1. repack.c: rename and unlink pack file if it existsJunio C Hamano, Feb 4, 2014
  2. Junio C HamanoFeb 4, 2014
  3. Jeff KingFeb 5, 2014
  4. Torsten BögershausenFeb 5, 2014
  5. Junio C HamanoFeb 5, 2014
  6. Jeff KingFeb 5, 2014
  7. Junio C HamanoFeb 5, 2014
  8. Jeff KingFeb 5, 2014
  9. Jeff KingFeb 5, 2014
  10. Junio C HamanoFeb 5, 2014
  11. Jeff KingFeb 5, 2014
  12. Junio C HamanoFeb 5, 2014
  13. Jeff KingFeb 5, 2014
  14. Torsten BögershausenFeb 5, 2014
  15. Junio C HamanoFeb 5, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.