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

[PATCH] do not use the no-op "-s" to diff-files.

From
Junio C Hamano <junkio@cox.net>
Date
Apr 22, 2006, 07:49 UTC
Message-ID
<7v1wvqnj6t.fsf@assigned-by-dhcp.cox.net>

The code to use '-s' flag to git-diff-files has been in cg-merge (and its ancestor) since this commit:

    commit 39c1ae5dfd229fb87c723fcf9737f29a506a31f9
    Author: Petr Baudis <pasky@ucw.cz>
    Date:   Tue Apr 19 02:42:08 2005 +0200

The "-s" flag has been a no-op to git-diff-files (but not for other diff siblings) for quite some time. For other diff siblings, the flag means "do not output anything", and it is primarily useful to squelch patch/raw from one-tree form of "diff-tree --pretty".

I am not sure if running diff-files to see if there is any difference and then running update-index --refresh when it is is a win -- I suspect you did this out of performance concerns, but it might be faster to let update-index to figure out if there is anything that needs to be done. So the first variant is the minimum impact (absolutely no semantic changes), the second variant _might_ be a performance improvement.

-jc

-- >8 -- First variant

diff --git a/cg-merge b/cg-merge
index 004b78a..24fb6ca 100755
--- a/cg-merge
+++ b/cg-merge
@@ -199,7 +199,7 @@ if { [ "$head" = "$base" ] || [ "$head" 
 fi
 
 
-[ "$(git-diff-files -s)" ] && git-update-index --refresh >/dev/null
+[ "$(git-diff-files)" ] && git-update-index --refresh >/dev/null
 
 if [ ! "$squash" ]; then
 	[ -s "$_git/squashing" ] && die "cannot combine squashing and non-squashing merges"

-- >8 --
Second variant

diff --git a/cg-merge b/cg-merge
index 24fb6ca..938d21a 100755
--- a/cg-merge
+++ b/cg-merge
@@ -199,7 +199,7 @@ if { [ "$head" = "$base" ] || [ "$head" 
 fi
 
 
-[ "$(git-diff-files -s)" ] && git-update-index --refresh >/dev/null
+git-update-index --refresh >/dev/null
 
 if [ ! "$squash" ]; then
 	[ -s "$_git/squashing" ] && die "cannot combine squashing and non-squashing merges"
Message 1 of 1 in “do not use the no-op "-s" to diff-files.”
  1. do not use the no-op "-s" to diff-files.Junio C Hamano, Apr 22, 2006

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.