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

git-mergetool reverse file ordering

From
LGLuis Gutierrez <luisgutz@gmail.com>
Date
Jul 27, 2016, 10:14 UTC
Message-ID
<CAD8hE_yzNZDPkxRy8s4Fy2_dZN5ppWzLM_2xc01C-VAdR1Pj_g@mail.gmail.com>
Hi,

Attached is a potential patch for reversing the order on which git-mergetool presents the files to merge.

Currently, when running git-mergetool, it performs a sort of the files to merge by alphabetical ordering. When working on C, this has the annoying effect of presenting the merge for a .c* files before the header files; which is always a bit harder to do. Reading the header first to figure out what the other dude changed is usually preferred.

The attach patch reverse the order (-r flag to sort) so *.h* are merged before *.c* files

PS, given the simplicity of the patch, I have not tested it.
Regards
Luis
diff --git a/git-mergetool.sh b/git-mergetool.sh
index bf86270..cce3b0d 100755
--- a/git-mergetool.sh
+++ b/git-mergetool.sh
@@ -453,10 +453,10 @@ then
 	then
 		files=$(git rerere remaining)
 	else
-		files=$(git ls-files -u | sed -e 's/^[^	]*	//' | sort -u)
+		files=$(git ls-files -u | sed -e 's/^[^	]*	//' | sort -u -r)
 	fi
 else
-	files=$(git ls-files -u -- "$@" | sed -e 's/^[^	]*	//' | sort -u)
+	files=$(git ls-files -u -- "$@" | sed -e 's/^[^	]*	//' | sort -u -r)
 fi
 
 if test -z "$files"
Next: David Aguilar
Message 1 of 10 in “git-mergetool reverse file ordering”
  1. Luis GutierrezJul 27, 2016
  2. David AguilarAug 14, 2016
  3. John KeepingAug 14, 2016
  4. Luis GutierrezAug 15, 2016
  5. David AguilarAug 17, 2016
  6. Johannes SixtAug 17, 2016
  7. Johannes SixtAug 17, 2016
  8. David AguilarAug 17, 2016
  9. Johannes SixtAug 17, 2016
  10. David AguilarAug 17, 2016

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.