[PATCH v3 1/4] Makefile: remove tracking of TCLTK_PATH

2012-12-16 Thread Christian Couder
It looks like we are tracking the value of TCLTK_PATH in the main
Makefile for no good reason, as this is done in git-gui too and the
GIT-GUI-VARS is not used in the Makefile.

This patch removes the useless code used to do this tracking.

Maybe this code should have been moved to gitk-git/Makefile by
62ba514 (Move gitk to its own subdirectory, 2007-11-17).

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore |  1 -
 Makefile   | 14 +-
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/.gitignore b/.gitignore
index f702415..6d69ae1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
 /GIT-BUILD-OPTIONS
 /GIT-CFLAGS
 /GIT-LDFLAGS
-/GIT-GUI-VARS
 /GIT-PREFIX
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
diff --git a/Makefile b/Makefile
index 4ad6fbd..585b2eb 100644
--- a/Makefile
+++ b/Makefile
@@ -2624,18 +2624,6 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_MAKE_OPTS)))'\' $@
 endif
 
-### Detect Tck/Tk interpreter path changes
-ifndef NO_TCLTK
-TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
-
-GIT-GUI-VARS: FORCE
-   @VARS='$(TRACK_VARS)'; \
-   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Tcl/Tk interpreter location; \
-   echo $$VARS $@; \
-fi
-endif
-
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) 
$(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2910,7 +2898,7 @@ ifndef NO_TCLTK
$(MAKE) -C gitk-git clean
$(MAKE) -C git-gui clean
 endif
-   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS 
GIT-BUILD-OPTIONS
+   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
 
 .PHONY: all install profile-clean clean strip
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/4] gitk-git/Makefile: track TCLTK_PATH as it used to be tracked

2012-12-16 Thread Christian Couder
In 62ba514 (Move gitk to its own subdirectory, 2007-11-17) some
code used to track TCLTK_PATH was left in the main Makefile instead
of being moved to the new Makefile that was created in gitk-git/.

The code left in the main Makefile should have been removed by a
previous patch in the same series as this one.

And this patch puts some code back to track TCLTK_PATH properly
where it should be, that is in gitk-git/Makefile.

Note that there is already some code to do that in git-gui/Makefile.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore  |  1 -
 gitk-git/.gitignore |  2 ++
 gitk-git/Makefile   | 16 ++--
 3 files changed, 16 insertions(+), 3 deletions(-)
 create mode 100644 gitk-git/.gitignore

diff --git a/.gitignore b/.gitignore
index 086c5af..56a4b2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -171,7 +171,6 @@
 /git-whatchanged
 /git-write-tree
 /git-core-*/?*
-/gitk-git/gitk-wish
 /gitweb/GITWEB-BUILD-OPTIONS
 /gitweb/gitweb.cgi
 /gitweb/static/gitweb.js
diff --git a/gitk-git/.gitignore b/gitk-git/.gitignore
new file mode 100644
index 000..d7ebcaf
--- /dev/null
+++ b/gitk-git/.gitignore
@@ -0,0 +1,2 @@
+/GIT-TCLTK-VARS
+/gitk-wish
diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index e1b6045..5acdc90 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -17,6 +17,16 @@ DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 bindir_SQ = $(subst ','\'',$(bindir))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 
+### Detect Tck/Tk interpreter path changes
+TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
+
+GIT-TCLTK-VARS: FORCE
+   @VARS='$(TRACK_TCLTK)'; \
+   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
+   echo 12 * new Tcl/Tk interpreter location; \
+   echo $$VARS $@; \
+   fi
+
 ## po-file creation rules
 XGETTEXT   ?= xgettext
 ifdef NO_MSGFMT
@@ -49,9 +59,9 @@ uninstall::
$(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
 
 clean::
-   $(RM) gitk-wish po/*.msg
+   $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
 
-gitk-wish: gitk
+gitk-wish: gitk GIT-TCLTK-VARS
$(QUIET_GEN)$(RM) $@ $@+  \
sed -e '1,3s|^exec .* $$0|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) 
$$0|' gitk $@+  \
chmod +x $@+  \
@@ -65,3 +75,5 @@ $(ALL_MSGFILES): %.msg : %.po
@echo Generating catalog $@
$(MSGFMT) --statistics --tcl $ -l $(basename $(notdir $)) -d $(dir $@)
 
+.PHONY: all install uninstall clean update-po
+.PHONY: FORCE
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/4] Makefile: replace echo 1... with echo ...

2012-12-16 Thread Christian Couder
This is clearer to many people this way.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 Makefile  | 10 +-
 git-gui/Makefile  |  6 +++---
 gitk-git/Makefile |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 7db8445..e055c9a 100644
--- a/Makefile
+++ b/Makefile
@@ -2183,7 +2183,7 @@ endef
 GIT-SCRIPT-DEFINES: FORCE
@FLAGS='$(SCRIPT_DEFINES)'; \
if test x$$FLAGS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new script parameters; \
+   echo 2 * new script parameters; \
echo $$FLAGS $@; \
 fi
 
@@ -2564,7 +2564,7 @@ TRACK_PREFIX = 
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 GIT-PREFIX: FORCE
@FLAGS='$(TRACK_PREFIX)'; \
if test x$$FLAGS != x`cat GIT-PREFIX 2/dev/null` ; then \
-   echo 12 * new prefix flags; \
+   echo 2 * new prefix flags; \
echo $$FLAGS GIT-PREFIX; \
fi
 
@@ -2573,7 +2573,7 @@ TRACK_CFLAGS = $(CC):$(subst 
','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
 GIT-CFLAGS: FORCE
@FLAGS='$(TRACK_CFLAGS)'; \
if test x$$FLAGS != x`cat GIT-CFLAGS 2/dev/null` ; then \
-   echo 12 * new build flags; \
+   echo 2 * new build flags; \
echo $$FLAGS GIT-CFLAGS; \
 fi
 
@@ -2582,7 +2582,7 @@ TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 GIT-LDFLAGS: FORCE
@FLAGS='$(TRACK_LDFLAGS)'; \
if test x$$FLAGS != x`cat GIT-LDFLAGS 2/dev/null` ; then \
-   echo 12 * new link flags; \
+   echo 2 * new link flags; \
echo $$FLAGS GIT-LDFLAGS; \
 fi
 
@@ -2631,7 +2631,7 @@ TRACK_PYTHON = $(subst 
','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
 GIT-PYTHON-VARS: FORCE
@VARS='$(TRACK_PYTHON)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Python interpreter location; \
+   echo 2 * new Python interpreter location; \
echo $$VARS $@; \
 fi
 endif
diff --git a/git-gui/Makefile b/git-gui/Makefile
index e22ba5c..e9c2bc3 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -254,7 +254,7 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
  auto_mkindex lib '*.tcl' \
| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
else \
-echo 12 * $(TCL_PATH) failed; using unoptimized loading; \
+echo 2 * $(TCL_PATH) failed; using unoptimized loading; \
 rm -f $@ ; \
 echo '# Autogenerated by git-gui Makefile' $@  \
 echo $@  \
@@ -274,8 +274,8 @@ TRACK_VARS = \
 GIT-GUI-VARS: FORCE
@VARS='$(TRACK_VARS)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new locations or Tcl/Tk interpreter; \
-   echo 1$@ $$VARS; \
+   echo 2 * new locations or Tcl/Tk interpreter; \
+   echo $@ $$VARS; \
fi
 
 ifdef GITGUI_MACOSXAPP
diff --git a/gitk-git/Makefile b/gitk-git/Makefile
index 5acdc90..c2df22f 100644
--- a/gitk-git/Makefile
+++ b/gitk-git/Makefile
@@ -23,7 +23,7 @@ TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
 GIT-TCLTK-VARS: FORCE
@VARS='$(TRACK_TCLTK)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Tcl/Tk interpreter location; \
+   echo 2 * new Tcl/Tk interpreter location; \
echo $$VARS $@; \
fi
 
-- 
1.8.1.rc1.2.g8740035

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 1/2] Makefile: remove tracking of TCLTK_PATH

2012-12-16 Thread Christian Couder
From: Junio C Hamano gits...@pobox.com

 Christian Couder chrisc...@tuxfamily.org writes:
 
 It looks like we are tracking the value of TCLTK_PATH in the main
 Makefile for no good reason, as this is done in git-gui too and the
 GIT-GUI-VARS is not used in the Makefile.
 
 This was added to the main Makefile when we slurped gitk to our
 project at the top-level, so I am not surprised if git-gui were
 not depending on it at all.
 
 A better explanation is that t62ba514 (Move gitk to its own
 subdirectory, 2007-11-17) should have moved these lines to
 gitk-git/Makefile (and I think we should move them there in a
 separate patch).

Yeah, I just sent an updated patch series that does this.

Thanks,
Christian. 
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Makefile: track TCLTK_PATH as it used to be tracked

2012-12-18 Thread Christian Couder
A long time ago, gitk used to live at the root of the git.git
repository. In 62ba514 (Move gitk to its own subdirectory,
2007-11-17) it was moved to a subdirectory, but some code used
to track TCLTK_PATH was left in the main Makefile instead
of being moved to the new Makefile that was created in gitk-git/.

The code left in the main Makefile in git.git should now have
been removed because it was found useless.

And this patch puts some code back to track TCLTK_PATH properly
where it should be.

Note that there is already some code to do that in git-gui.

At the same time this patch creates a .gitignore and also marks
some targets in the Makefile as PHONY.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi Paul,

In this thread:

http://thread.gmane.org/gmane.comp.version-control.git/211641

Junio asked me to send you this patch.
So here it is, for you to apply to your tree.

Thanks,
Christian.

 .gitignore |  2 ++
 Makefile   | 16 ++--
 2 files changed, 16 insertions(+), 2 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000..d7ebcaf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+/GIT-TCLTK-VARS
+/gitk-wish
diff --git a/Makefile b/Makefile
index e1b6045..5acdc90 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,16 @@ DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 bindir_SQ = $(subst ','\'',$(bindir))
 TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
 
+### Detect Tck/Tk interpreter path changes
+TRACK_TCLTK = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
+
+GIT-TCLTK-VARS: FORCE
+   @VARS='$(TRACK_TCLTK)'; \
+   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
+   echo 12 * new Tcl/Tk interpreter location; \
+   echo $$VARS $@; \
+   fi
+
 ## po-file creation rules
 XGETTEXT   ?= xgettext
 ifdef NO_MSGFMT
@@ -49,9 +59,9 @@ uninstall::
$(RM) '$(DESTDIR_SQ)$(bindir_SQ)'/gitk
 
 clean::
-   $(RM) gitk-wish po/*.msg
+   $(RM) gitk-wish po/*.msg GIT-TCLTK-VARS
 
-gitk-wish: gitk
+gitk-wish: gitk GIT-TCLTK-VARS
$(QUIET_GEN)$(RM) $@ $@+  \
sed -e '1,3s|^exec .* $$0|exec $(subst |,'\|',$(TCLTK_PATH_SQ)) 
$$0|' gitk $@+  \
chmod +x $@+  \
@@ -65,3 +75,5 @@ $(ALL_MSGFILES): %.msg : %.po
@echo Generating catalog $@
$(MSGFMT) --statistics --tcl $ -l $(basename $(notdir $)) -d $(dir $@)
 
+.PHONY: all install uninstall clean update-po
+.PHONY: FORCE
-- 
1.8.1.rc1.2.g8740035

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 3/4] gitk-git/Makefile: track TCLTK_PATH as it used to be tracked

2012-12-18 Thread Christian Couder
From: Junio C Hamano gits...@pobox.com

  .gitignore  |  1 -
  gitk-git/.gitignore |  2 ++
  gitk-git/Makefile   | 16 ++--
 
 I'll apply the .gitignore part to my tree, but could you split the
 rest out and have Paul apply to his tree at
 
 git://ozlabs.org/~paulus/gitk.git

Ok, I just sent the rest to Paul and I am going to send you an updated
series for you.

Regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 1/3] Makefile: remove tracking of TCLTK_PATH

2012-12-18 Thread Christian Couder
It looks like we are tracking the value of TCLTK_PATH in the main
Makefile for no good reason.

This patch removes the useless code used to do this tracking.

Maybe this code should have been moved to gitk-git/Makefile by
62ba514 (Move gitk to its own subdirectory, 2007-11-17).
A patch to do that has just been sent to Paul Mackerras, the gitk
maintainer.

While at it, this patch removes /gitk-git/gitk-wish from
.gitignore as it should be in /gitk-git/.gitignore and the patch
sent to Paul put it there.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi Junio,

I removed from the commit message everything that talked about
git-gui. And this patch removes /gitk-git/gitk-wish from
.gitignore.

Regards,
Christian.

 .gitignore |  2 --
 Makefile   | 14 +-
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index f702415..64a454b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
 /GIT-BUILD-OPTIONS
 /GIT-CFLAGS
 /GIT-LDFLAGS
-/GIT-GUI-VARS
 /GIT-PREFIX
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
@@ -171,7 +170,6 @@
 /git-whatchanged
 /git-write-tree
 /git-core-*/?*
-/gitk-git/gitk-wish
 /gitweb/GITWEB-BUILD-OPTIONS
 /gitweb/gitweb.cgi
 /gitweb/static/gitweb.js
diff --git a/Makefile b/Makefile
index 4ad6fbd..585b2eb 100644
--- a/Makefile
+++ b/Makefile
@@ -2624,18 +2624,6 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_MAKE_OPTS)))'\' $@
 endif
 
-### Detect Tck/Tk interpreter path changes
-ifndef NO_TCLTK
-TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
-
-GIT-GUI-VARS: FORCE
-   @VARS='$(TRACK_VARS)'; \
-   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Tcl/Tk interpreter location; \
-   echo $$VARS $@; \
-fi
-endif
-
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) 
$(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2910,7 +2898,7 @@ ifndef NO_TCLTK
$(MAKE) -C gitk-git clean
$(MAKE) -C git-gui clean
 endif
-   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS 
GIT-BUILD-OPTIONS
+   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
 
 .PHONY: all install profile-clean clean strip
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 2/3] Makefile: detect when PYTHON_PATH changes

2012-12-18 Thread Christian Couder
When make is run, the python scripts are created from *.py files that
are changed to use the python given by PYTHON_PATH. And PYTHON_PATH
is set by default to /usr/bin/python on Linux.

This is nice except when you run make another time setting a
different PYTHON_PATH, because, as the python scripts have already
been created, make finds nothing to do.

The goal of this patch is to detect when the PYTHON_PATH changes and
to create the python scripts again when this happens. To do that we
use the same trick that is done to track other variables like prefix,
flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file
with the PYTHON_PATH and check if it changed.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore |  1 +
 Makefile   | 16 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 64a454b..56a4b2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 /GIT-CFLAGS
 /GIT-LDFLAGS
 /GIT-PREFIX
+/GIT-PYTHON-VARS
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
 /GIT-VERSION-FILE
diff --git a/Makefile b/Makefile
index 585b2eb..7db8445 100644
--- a/Makefile
+++ b/Makefile
@@ -2245,7 +2245,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : 
unimplemented.sh
 endif # NO_PERL
 
 ifndef NO_PYTHON
-$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
$(QUIET_GEN)$(RM) $@ $@+  \
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2624,6 +2624,18 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_MAKE_OPTS)))'\' $@
 endif
 
+### Detect Python interpreter path changes
+ifndef NO_PYTHON
+TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
+
+GIT-PYTHON-VARS: FORCE
+   @VARS='$(TRACK_PYTHON)'; \
+   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
+   echo 12 * new Python interpreter location; \
+   echo $$VARS $@; \
+fi
+endif
+
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) 
$(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2899,7 +2911,7 @@ ifndef NO_TCLTK
$(MAKE) -C git-gui clean
 endif
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
-   $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
+   $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
 
 .PHONY: all install profile-clean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v4 3/3] Makefile: replace echo 1... with echo ...

2012-12-18 Thread Christian Couder
This is clearer to many people this way.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 Makefile | 10 +-
 git-gui/Makefile |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile
index 7db8445..e055c9a 100644
--- a/Makefile
+++ b/Makefile
@@ -2183,7 +2183,7 @@ endef
 GIT-SCRIPT-DEFINES: FORCE
@FLAGS='$(SCRIPT_DEFINES)'; \
if test x$$FLAGS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new script parameters; \
+   echo 2 * new script parameters; \
echo $$FLAGS $@; \
 fi
 
@@ -2564,7 +2564,7 @@ TRACK_PREFIX = 
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 GIT-PREFIX: FORCE
@FLAGS='$(TRACK_PREFIX)'; \
if test x$$FLAGS != x`cat GIT-PREFIX 2/dev/null` ; then \
-   echo 12 * new prefix flags; \
+   echo 2 * new prefix flags; \
echo $$FLAGS GIT-PREFIX; \
fi
 
@@ -2573,7 +2573,7 @@ TRACK_CFLAGS = $(CC):$(subst 
','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
 GIT-CFLAGS: FORCE
@FLAGS='$(TRACK_CFLAGS)'; \
if test x$$FLAGS != x`cat GIT-CFLAGS 2/dev/null` ; then \
-   echo 12 * new build flags; \
+   echo 2 * new build flags; \
echo $$FLAGS GIT-CFLAGS; \
 fi
 
@@ -2582,7 +2582,7 @@ TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 GIT-LDFLAGS: FORCE
@FLAGS='$(TRACK_LDFLAGS)'; \
if test x$$FLAGS != x`cat GIT-LDFLAGS 2/dev/null` ; then \
-   echo 12 * new link flags; \
+   echo 2 * new link flags; \
echo $$FLAGS GIT-LDFLAGS; \
 fi
 
@@ -2631,7 +2631,7 @@ TRACK_PYTHON = $(subst 
','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
 GIT-PYTHON-VARS: FORCE
@VARS='$(TRACK_PYTHON)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Python interpreter location; \
+   echo 2 * new Python interpreter location; \
echo $$VARS $@; \
 fi
 endif
diff --git a/git-gui/Makefile b/git-gui/Makefile
index e22ba5c..e9c2bc3 100644
--- a/git-gui/Makefile
+++ b/git-gui/Makefile
@@ -254,7 +254,7 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
  auto_mkindex lib '*.tcl' \
| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
else \
-echo 12 * $(TCL_PATH) failed; using unoptimized loading; \
+echo 2 * $(TCL_PATH) failed; using unoptimized loading; \
 rm -f $@ ; \
 echo '# Autogenerated by git-gui Makefile' $@  \
 echo $@  \
@@ -274,8 +274,8 @@ TRACK_VARS = \
 GIT-GUI-VARS: FORCE
@VARS='$(TRACK_VARS)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new locations or Tcl/Tk interpreter; \
-   echo 1$@ $$VARS; \
+   echo 2 * new locations or Tcl/Tk interpreter; \
+   echo $@ $$VARS; \
fi
 
 ifdef GITGUI_MACOSXAPP
-- 
1.8.1.rc1.2.g8740035

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Makefile: replace echo 1... with echo ...

2012-12-18 Thread Christian Couder
This is clearer to many people this way.

A similar patch has been sent to the git mailing list
for git.git.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi Pat,

Here is a patch to apply to your git-gui tree following this
discussion:

http://thread.gmane.org/gmane.comp.version-control.git/211532/

Thanks,
Christian.

 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index e22ba5c..e9c2bc3 100644
--- a/Makefile
+++ b/Makefile
@@ -254,7 +254,7 @@ lib/tclIndex: $(ALL_LIBFILES) GIT-GUI-VARS
  auto_mkindex lib '*.tcl' \
| $(TCL_PATH) $(QUIET_2DEVNULL); then : ok; \
else \
-echo 12 * $(TCL_PATH) failed; using unoptimized loading; \
+echo 2 * $(TCL_PATH) failed; using unoptimized loading; \
 rm -f $@ ; \
 echo '# Autogenerated by git-gui Makefile' $@  \
 echo $@  \
@@ -274,8 +274,8 @@ TRACK_VARS = \
 GIT-GUI-VARS: FORCE
@VARS='$(TRACK_VARS)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new locations or Tcl/Tk interpreter; \
-   echo 1$@ $$VARS; \
+   echo 2 * new locations or Tcl/Tk interpreter; \
+   echo $@ $$VARS; \
fi
 
 ifdef GITGUI_MACOSXAPP
-- 
1.8.1.rc1.2.g8740035

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 1/3] Makefile: remove tracking of TCLTK_PATH

2012-12-18 Thread Christian Couder
It looks like we are tracking the value of TCLTK_PATH in the main
Makefile for no good reason.

This patch removes the useless code used to do this tracking.

Maybe this code should have been moved to gitk-git/Makefile by
62ba514 (Move gitk to its own subdirectory, 2007-11-17).
A patch to do that has just been sent to Paul Mackerras, the gitk
maintainer.

While at it, this patch removes /gitk-git/gitk-wish from
.gitignore as it should be in /gitk-git/.gitignore and the patch
sent to Paul put it there.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore |  2 --
 Makefile   | 14 +-
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/.gitignore b/.gitignore
index f702415..64a454b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,6 @@
 /GIT-BUILD-OPTIONS
 /GIT-CFLAGS
 /GIT-LDFLAGS
-/GIT-GUI-VARS
 /GIT-PREFIX
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
@@ -171,7 +170,6 @@
 /git-whatchanged
 /git-write-tree
 /git-core-*/?*
-/gitk-git/gitk-wish
 /gitweb/GITWEB-BUILD-OPTIONS
 /gitweb/gitweb.cgi
 /gitweb/static/gitweb.js
diff --git a/Makefile b/Makefile
index 4ad6fbd..585b2eb 100644
--- a/Makefile
+++ b/Makefile
@@ -2624,18 +2624,6 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_MAKE_OPTS)))'\' $@
 endif
 
-### Detect Tck/Tk interpreter path changes
-ifndef NO_TCLTK
-TRACK_VARS = $(subst ','\'',-DTCLTK_PATH='$(TCLTK_PATH_SQ)')
-
-GIT-GUI-VARS: FORCE
-   @VARS='$(TRACK_VARS)'; \
-   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Tcl/Tk interpreter location; \
-   echo $$VARS $@; \
-fi
-endif
-
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) 
$(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2910,7 +2898,7 @@ ifndef NO_TCLTK
$(MAKE) -C gitk-git clean
$(MAKE) -C git-gui clean
 endif
-   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS 
GIT-BUILD-OPTIONS
+   $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
$(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
 
 .PHONY: all install profile-clean clean strip
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 3/3] Makefile: replace echo 1... with echo ...

2012-12-18 Thread Christian Couder
This is clearer to many people this way.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 Makefile | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 7db8445..e055c9a 100644
--- a/Makefile
+++ b/Makefile
@@ -2183,7 +2183,7 @@ endef
 GIT-SCRIPT-DEFINES: FORCE
@FLAGS='$(SCRIPT_DEFINES)'; \
if test x$$FLAGS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new script parameters; \
+   echo 2 * new script parameters; \
echo $$FLAGS $@; \
 fi
 
@@ -2564,7 +2564,7 @@ TRACK_PREFIX = 
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\
 GIT-PREFIX: FORCE
@FLAGS='$(TRACK_PREFIX)'; \
if test x$$FLAGS != x`cat GIT-PREFIX 2/dev/null` ; then \
-   echo 12 * new prefix flags; \
+   echo 2 * new prefix flags; \
echo $$FLAGS GIT-PREFIX; \
fi
 
@@ -2573,7 +2573,7 @@ TRACK_CFLAGS = $(CC):$(subst 
','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME)
 GIT-CFLAGS: FORCE
@FLAGS='$(TRACK_CFLAGS)'; \
if test x$$FLAGS != x`cat GIT-CFLAGS 2/dev/null` ; then \
-   echo 12 * new build flags; \
+   echo 2 * new build flags; \
echo $$FLAGS GIT-CFLAGS; \
 fi
 
@@ -2582,7 +2582,7 @@ TRACK_LDFLAGS = $(subst ','\'',$(ALL_LDFLAGS))
 GIT-LDFLAGS: FORCE
@FLAGS='$(TRACK_LDFLAGS)'; \
if test x$$FLAGS != x`cat GIT-LDFLAGS 2/dev/null` ; then \
-   echo 12 * new link flags; \
+   echo 2 * new link flags; \
echo $$FLAGS GIT-LDFLAGS; \
 fi
 
@@ -2631,7 +2631,7 @@ TRACK_PYTHON = $(subst 
','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
 GIT-PYTHON-VARS: FORCE
@VARS='$(TRACK_PYTHON)'; \
if test x$$VARS != x`cat $@ 2/dev/null` ; then \
-   echo 12 * new Python interpreter location; \
+   echo 2 * new Python interpreter location; \
echo $$VARS $@; \
 fi
 endif
-- 
1.8.1.rc1.2.g8740035

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v5 2/3] Makefile: detect when PYTHON_PATH changes

2012-12-18 Thread Christian Couder
When make is run, the python scripts are created from *.py files that
are changed to use the python given by PYTHON_PATH. And PYTHON_PATH
is set by default to /usr/bin/python on Linux.

This is nice except when you run make another time setting a
different PYTHON_PATH, because, as the python scripts have already
been created, make finds nothing to do.

The goal of this patch is to detect when the PYTHON_PATH changes and
to create the python scripts again when this happens. To do that we
use the same trick that is done to track other variables like prefix,
flags, tcl/tk path and shell path. We update a GIT-PYTHON-VARS file
with the PYTHON_PATH and check if it changed.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore |  1 +
 Makefile   | 16 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 64a454b..56a4b2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
 /GIT-CFLAGS
 /GIT-LDFLAGS
 /GIT-PREFIX
+/GIT-PYTHON-VARS
 /GIT-SCRIPT-DEFINES
 /GIT-USER-AGENT
 /GIT-VERSION-FILE
diff --git a/Makefile b/Makefile
index 585b2eb..7db8445 100644
--- a/Makefile
+++ b/Makefile
@@ -2245,7 +2245,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : 
unimplemented.sh
 endif # NO_PERL
 
 ifndef NO_PYTHON
-$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX
+$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX GIT-PYTHON-VARS
 $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
$(QUIET_GEN)$(RM) $@ $@+  \
INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \
@@ -2624,6 +2624,18 @@ ifdef GIT_PERF_MAKE_OPTS
@echo GIT_PERF_MAKE_OPTS=\''$(subst ','\'',$(subst 
','\'',$(GIT_PERF_MAKE_OPTS)))'\' $@
 endif
 
+### Detect Python interpreter path changes
+ifndef NO_PYTHON
+TRACK_PYTHON = $(subst ','\'',-DPYTHON_PATH='$(PYTHON_PATH_SQ)')
+
+GIT-PYTHON-VARS: FORCE
+   @VARS='$(TRACK_PYTHON)'; \
+   if test x$$VARS != x`cat $@ 2/dev/null` ; then \
+   echo 12 * new Python interpreter location; \
+   echo $$VARS $@; \
+fi
+endif
+
 test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) 
$(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))
 
 all:: $(TEST_PROGRAMS) $(test_bindir_programs)
@@ -2899,7 +2911,7 @@ ifndef NO_TCLTK
$(MAKE) -C git-gui clean
 endif
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
-   $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES
+   $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES GIT-PYTHON-VARS
 
 .PHONY: all install profile-clean clean strip
 .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
-- 
1.8.1.rc1.2.g8740035


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] learn to pick/revert into unborn branch

2012-12-22 Thread Christian Couder
On Sun, Dec 23, 2012 at 7:24 AM, Martin von Zweigbergk
martinv...@gmail.com wrote:

 As for use cases, I didn't consider that much more than that it might
 be useful for implementing git rebase --root. I haven't implemented
 that yet, so I can't say for sure that it will work out.

 One use case might be to rewrite history by creating an new unborn
 branch and picking the initial commit and a subset of other commits.
 Anyway, I didn't implement it because I thought it would be very
 useful, but mostly because I just thought it should work (for
 completeness).

I agree that it would be nice if it worked.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: recovering a corrupted git repo

2013-01-07 Thread Christian Couder
On Mon, Jan 7, 2013 at 4:44 AM, Phillip Susi ps...@ubuntu.com wrote:

 I have not had any issue until I ran a git fsck recently, which
 repored gzip and crc errors in some pack files.  git fsck does not
 seem to repair the errors, only report them.  I would like to try to
 rebuild my repository, without downloading any more from the origin
 than I have to.  All of the commits I have added seem to still be
 intact, so I assume the corruption in somewhere in the upstream
 history packs.

 How can I correct the errors, and fetch the corrupted upstream
 history, while preserving my patches?  So far I have exported my
 patches as bundles, and made a fresh clone from upstream, then pulled
 the bundles back in, but there must be a better way that only fetches
 the corrupted bits from upstream?

The documentation about fixing broken repo is this one:

https://git.wiki.kernel.org/index.php/GitFaq#fix-broken-repo

Hope this helps,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Google Summer of Code 2013 (GSoC13)

2013-02-19 Thread Christian Couder
On Mon, Feb 18, 2013 at 9:02 PM, Jens Lehmann jens.lehm...@web.de wrote:
 Am 18.02.2013 20:34, schrieb Jonathan Nieder:
 That said, I won't have time to mentor a project on my own.  It takes
 a lot of time (or luck, to get the student that doesn't need
 mentoring).

 That's my experience too. Also I think it really makes sense to have a
 co-mentor so you can balance the load a bit.

 I'd be happy to help on a project with 1 or 2 co-mentors.

 Same here.

I am ok to be mentor or co-mentor.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Google Summer of Code 2013 (GSoC13)

2013-02-20 Thread Christian Couder
Hi,

On Wed, Feb 20, 2013 at 7:50 AM, Shawn Pearce spea...@spearce.org wrote:
 On Mon, Feb 18, 2013 at 9:42 AM, Jeff King p...@peff.net wrote:
 On Mon, Feb 18, 2013 at 06:23:01PM +0100, Thomas Rast wrote:

 * We need an org admin.  AFAIK this was done by Peff and Shawn in
   tandem last year.  Would you do it again?

 I will do it again, if people feel strongly about Git being a part of
 it. However, I have gotten a little soured on the GSoC experience. Not
 because of anything Google has done; it's a good idea, and I think they
 do a fine of administering the program. But I have noticed that the work
 that comes out of GSoC the last few years has quite often not been
 merged, or not made a big impact in the codebase, and nor have the
 participants necessarily stuck around.

 This.

I think it is ok if the code doesn't make a big impact in the code
base and it is ok too if the participants don't stuck around.
Of course I would love both of these things to happen, but we have to
be realistic and just stop expecting it.

 I actually think Git should take a year off from GSoC and not
 participate. Consequently I will not be volunteering as backup org
 admin.

 Git has been involved since 2007. In all of that time we have had very
 few student projects merge successfully into their upstream project
 (e.g. git.git, JGit or libgit2) before the end of GSoC. Even fewer
 students have stuck around and remained active contributors. When I
 look at the amount of effort we contributors put into GSoC, I think we
 are misusing our limited time and resources.

I don't think so, at least not for me. I feel happy to mentor or
co-mentor GSoC student and I don't think I would work much more on git
these days if git was not participating to the GSoC.

 The intention of the GSoC
 program is to grow new open source developers, and increase our
 community of contributors. Somehow I think Git is falling well short
 of its potential here. This is especially true if you compare Git's
 GSoC program to some other equally long-running GSoC programs.

 And I do not want to blame the students here (some of whom are on the cc
 list :) ). They are certainly under no obligation to stick around after
 GSoC ends, and I know they have many demands on their time. But I am
 also thinking about what Git wants to get out of GSoC (and to my mind,
 the most important thing is contributors).

 I agree, our students have been pretty terrific. I think the
 shortcomings in our GSoC program are on the mentoring side. Our
 program has not really had much success with keeping students active
 and engaged post GSoC. I see that primarily as a mentoring failure.
 And its one we keep repeating each year.

I don't quite agree with this. My experience has been the following:

- 2008: the student I co-mentored did pretty well though he didn't
send to the list his patch series early enough.
So there was some mentoring failure, but anyway the student stuck
around for 9 months and managed to get 53 commits merged.

- 2009: if I remember well, it was decided to have only 2 GSoC student
that year, and that 5 people would co-mentor both of them together.
One of the student did nearly nothing. The other one sent his patch
series too late to the list. My opinion is that he relied too much on
the people mentoring him and he worked on something that was difficult
to merge.

- 2010: the student I co-mentored stopped working 3 weeks before the
mid-term evaluation despite some warnings from me and Peff, and he had
not been doing much a few weeks before that, so we decided to fail him
at the mid term evaluation.

- 2011: I was lucky to mentor Ram who did well and is still around.

So my opinion is that we have some students who are just not doing
enough (2 out of 5).
Then we have some good students, 2 out of 5 who could sometimes do
better if we insisted more on submitting earlier to the mailing list.
And we have a few students (1 out of 5) who work difficult to merge
projects and who could do better if we insisted more on submitting
earlier to the mailing list.

So my conclusions are:
- it's quite often going well or well enough
- when it's not going well often the student is responsible
- yes, we could improve mentoring by providing better projects and
insisting even more on submitting earlier

[...]

   - There is also the angle that even if _Git_ doesn't benefit directly
 from people sticking around, those people may float into other open
 source projects and work on them. Which makes the world a better
 place on the whole.

 Yes, sure, OK. But if Git doesn't participate in GSoC this year
 another org will, and this same benefit will still be had by the
 greater open source community.

The greater open source community benefits a lot these days when Git
is improved and get new contributors, as git is now by far the most
widely used version control system in the open source community.
So my opinion is that we should have has many GSoC student as we can

Re: Bug: git web--browse doesn't recognise browser on OS X

2013-03-15 Thread Christian Couder
Hi,

On Thu, Mar 14, 2013 at 12:39 PM, Timo Sand timo.j.s...@gmail.com wrote:
 Hi

 I tried to open a website by runnin 'git web--browse http://google.com'
 and it replied 'No known browser available'.

First git web--browse is a plumbing shell script to display
documentation on a web browser when you type something like git help
-w log.
It is not really supposed to be used directly by the user. On OS X it
might be simpler to just type open http://google.com;.

That said there is the following in it to make it work on OS X:

# SECURITYSESSIONID indicates an OS X GUI login session
if test -n $SECURITYSESSIONID \
-o $TERM_PROGRAM = Apple_Terminal ; then
browser_candidates=open $browser_candidates
fi

So I guess that you don't have SECURITYSESSIONID set in your terminal
and you are not using Apple Terminal.

As I am not using OS X, I have no idea how to improve the script in this case.

 I also tried with '--browser=chrome' and '--browser=google-chrome' but
 the responded with 'The browser chrome is not available as 'chrome'.'

Could you try something like: chromium http://google.com; or
chromium-browser http://google.com;
If it works, then using 'git web--browse' with '--browser=chromium' or
'--browser=chromium-browser' should work.

Otherwise did you try chrome http://google.com; and google-chrome
http://google.com;?

 I expected the command to open a new tab in my browser in each of the 3 tries.
 This has worked for my system before.

 OS X 10.8.2, git 1.8.2, Google Chrome 27.0.1438.7 dev

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Bug: git web--browse doesn't recognise browser on OS X

2013-03-24 Thread Christian Couder
On Fri, Mar 22, 2013 at 6:36 PM, John Szakmeister j...@szakmeister.net wrote:
 On Fri, Mar 22, 2013 at 12:19 PM, Timo Sand timo.j.s...@gmail.com wrote:
 Hi,

 well my use case is actually that I'm trying to use the gem
 'gem-browse' which uses 'git web--browse'
 I'm not using Apple Terminal, I'm using iTerm2 and there doesn't seem
 to be a SECURITYSESSIONID set, at least echo didn't find any. But
 neither did I find it on Apple Terminal either.

 I noticed this the other day, but I think SECURITYSESSIONID only gets
 set when Screen Sharing is enabled.  I had Screen Sharing enabled,
 launched iTerm2 and saw the variable.  I closed iTerm2, turned off
 Screen Sharing, and relaunched iTerm2 to find the variable missing.
 As a result, I'm not SECURITYSESSIONID is a good mechanism for
 determining whether the terminal is associated a GUI or not.
 Unfortunately, I don't know of a better way.

 What troubles me is that this issue has only arisen recently, earlier
 this worked fine for me

 The following patch fixes the issue by recognizing iTerm2 as a GUI terminal.

Your patch looks good to me, and I cannot really test it as I don't have a Mac.
Could you just had some of the explanations you gave above to the
commit message?

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] git-web--browse: recognize iTerm as a GUI terminal on OS X

2013-03-25 Thread Christian Couder
On Mon, Mar 25, 2013 at 11:13 AM, John Szakmeister j...@szakmeister.net wrote:

 Here's an updated patch.

Thank you for it. For what it's worth:

Acked-by: Christian Couder chrisc...@tuxfamily.org

 I also noticed that git-bisect.sh is
 also trying to determine if a GUI is present by looking for
 SECURITYSESSIONID as well.  I wonder if it would be better to
 create a shell function in git-sh-setup.sh that the two scripts
 could use?

Yeah, it might be a good idea to have some common functions to
determine if a GUI is present.
Maybe you could start with an os_x_gui_present() function in another
patch on top of this one.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Git and GSoC 2013

2013-03-27 Thread Christian Couder
On Wed, Mar 27, 2013 at 7:52 PM, Jonathan Nieder jrnie...@gmail.com wrote:
 Jeff King wrote:

 There was a big thread about a month ago on whether Git should do Google
 Summer of Code this year[1].

I think we should do it.

It looks strange to me to say that students are great and at the same
time that we should not do it.

Let's give them and us one more chance do to well. This is the only
way we can improve.

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Git and GSoC 2013

2013-03-28 Thread Christian Couder
On Thu, Mar 28, 2013 at 5:45 PM, Junio C Hamano gits...@pobox.com wrote:
 Christian Couder christian.cou...@gmail.com writes:

 On Wed, Mar 27, 2013 at 7:52 PM, Jonathan Nieder jrnie...@gmail.com wrote:
 Jeff King wrote:

 There was a big thread about a month ago on whether Git should do Google
 Summer of Code this year[1].

 I think we should do it.

 It looks strange to me to say that students are great and at the same
 time that we should not do it.

 Let's give them and us one more chance do to well. This is the only
 way we can improve.

 Do you mean we should be doing the same thing over and over again
 and expecting different results?  Einstein may not like it, and I
 certainly don't.

No, I don't mean we should be doing the same. I agree that smaller
projects are helpful and insisting on submitting right away on the
mailing list is helpful.
But if we don't even try we have no chance to see if it works. We just
lose time.

 What I gathered from the discussion so far is that everybody agrees
 that our mentoring has been suboptimal in various ways (not enough
 encouragement to engage with the community early, working in the
 cave for too long, biting too much to chew etc.).  What makes you
 think we would do better this year?

The fact that we will be more conscious that we need smaller projects
and that we need to push even more for students to send their patch
soon on the mailing list.

If it doesn't work at all we will be set and we will know that there
is not much we can do to make it work.

If we don't even try we will not know soon, so not be able to improve
or decide to stop.

It's like software or science. If you don't test soon your hypothesis
you don't progress fast.

Or do you think we just stand no chance to progress?

By the way we say that students should post soon to the mailing list
to get a feedback soon, but it looks like we don't want to try our
hypothesis around mentoring as soon as we can.
Doesn't it sound strange to you? Aren't we saying do as I say not as I do?

 We have a track record of being not great at mentoring, and we
 haven't made an effort to improve it. is a perfectly valid and
 humble reason to excuse ourselves from this year's GSoC.

It is also a perfectly valid justification to decide to make an effort
to improve our mentoring and to try again.

 Students are great is immaterial.

We are not great at mentoring is as much immaterial.

 In fact, if they are great, I think it is better to give them a
 chance to excel by working with organizations that can mentor them
 better, instead of squandering their time and GSoC's money for
 another failure, until _we_ are ready to take great students.

How do we know we are ready if we don't try?

By waiting we just lose the experience we already have, because some
mentors might not be around next year, or they will not remember well
about the process.

And some organizations that will perhaps be accepted, if we decide not
to do it, might have no mentoring experience at all. How do you know
they will mentor students better than what we have been doing?

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: Very useful script to SVG graph the git commits from a file orientated view

2013-04-09 Thread Christian Couder
Hi,

On Tue, Apr 9, 2013 at 10:55 AM, Jeremy Rosen jeremy.ro...@openwide.fr wrote:
 looking a little bit more into this, I was very suprised

 there seems to be little/no tools in the git ecosystem that studies the 
 dependencies between commits based on the file they modified and/or the 
 conflict they would cause.

 Is there any pre-existing tool to do that ? It can be done with git-log 
 --name-only(the graph_git.pl is just a graphing layer above that command) but 
 i'm suprised that I couldn't find anything else

 And that was at the file level, is there any tool to help find what commits 
 can be reordered without causing conflicts ? I am not sure if there is an 
 easy way to extract potential conflict information from git...

It looks like this tool will do Proactive Merge Conflicts Detection:

http://commitq.com/

But it's true that it would be nice if there was something in git itself.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bisect: Store first bad commit as comment in log file

2013-04-14 Thread Christian Couder
From: Torstein Hegge he...@resisty.net
Subject: [PATCH] bisect: Store first bad commit as comment in log file
Date: Sat, 13 Apr 2013 17:22:57 +0200

 When bisect successfully finds a single revision, the first bad commit
 should be shown to human readers of 'git bisect log'.
 
 This resolves the apparent disconnect between the bisection result and
 the log when a bug reporter says I know that the first bad commit is
 $rev, as you can see from $(git bisect log).

I agree that it's a good idea to do that.

I wonder if we should also write something into the bisect log if for
example the bisection stopped because there are only 'skip'ped commits
left to test. But maybe this could go into another patch after this
one.
 
 Signed-off-by: Torstein Hegge he...@resisty.net
 ---
 I don't know how useful the added test is, I didn't find any existing
 tests that looks at the comment parts of bisect log.

Thanks for adding a test. It's always appreciated.

  git-bisect.sh   |8 +++-
  t/t6030-bisect-porcelain.sh |   18 ++
  2 files changed, 25 insertions(+), 1 deletion(-)
 
 diff --git a/git-bisect.sh b/git-bisect.sh
 index 99efbe8..c58eea7 100755
 --- a/git-bisect.sh
 +++ b/git-bisect.sh
 @@ -311,7 +311,13 @@ bisect_next() {
   res=$?
  
   # Check if we should exit because bisection is finished
 - test $res -eq 10  exit 0
 + if test $res -eq 10
 + then
 + bad_rev=$(git show-ref --hash --verify refs/bisect/bad)

I had a look to make sure that refs/bisect/bad always refered to the
first bad commit at this point, and it is true indeed.

Maybe you could have used git rev-parse --verify instead of git
show-ref --hash --verify. It looks simpler to me.

And maybe, just in case, you could have added: || die $(gettext Bad rev: 
refs/bisect/bad)

Otherwise this patch looks good to me.

 + bad_commit=$(git show-branch $bad_rev)
 + echo # first bad commit: $bad_commit $GIT_DIR/BISECT_LOG
 + exit 0
 + fi

Thanks,
Christian.

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bisect: Store first bad commit as comment in log file

2013-04-24 Thread Christian Couder
From: Torstein Hegge he...@resisty.net
Subject: Re: [PATCH] bisect: Store first bad commit as comment in log file
Date: Tue, 23 Apr 2013 00:20:58 +0200

 On Mon, Apr 22, 2013 at 14:13:00 -0700, Junio C Hamano wrote:
 Torstein Hegge he...@resisty.net writes:
 
  I took another look at this. I wasn't able to come up with anything
  useful for the The merge base $rev is bad case, but for the only
  skipped commits left to test case one could do something like this.
 
 We skipped them because we can gain _no_ information from testing
 these commits. They are not even possibly bad, but are unknown.
 
 So it feels to me that by definition listing them would not be
 useful. What am I missing?
 
 The information lies in that those commits are the only commits with an
 unknown state. So if the bisecter hands off the bisect log to someone
 else when they can't test further, the current status is recorded.

Yeah, I think it is a good enough reason for your patch.
 
 I think part of the reason I started looking at this is that there are
 no good way to see what git said after the previous 'git bisect
 good/bad' if the terminal output is lost. And lost terminal output is
 fairly likely if you are bisecting something that requires reboots for
 each test.

Yeah, I agree.

 But I don't feel very strongly about this. It was based on Christian's
 idea, so unless he comes up with some compelling arguments I'll drop it.

I think your arguments are good enough.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: git bisect should accept paths-to-be-excluded

2013-09-17 Thread Christian Couder
Hi,

On Mon, Sep 16, 2013 at 2:39 PM, Toralf Förster toralf.foers...@gmx.de wrote:
 I'm bisecting a linux kernel issue and want to ignore all commits just
 touching something in ./drives/staging.

 Currently the only way would be to specify all dir/subdir combination
 under ./linux except that particular directory, right ?

Yeah, you are right, currently the only way would be to specify all
dir/subdir combination
under ./linux except the particular directory you want to exclude.

It might indeed be useful to have a way to exclude some directories or files.

In practice though, as git bisect is a kind of binary search, if what
you want to exclude is exclusively touched by half the commits, it
will only add one more bisection step if you don't exclude it.

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: RFC: git bisect should accept paths-to-be-excluded

2013-09-17 Thread Christian Couder
On Tue, Sep 17, 2013 at 10:21 AM, Matthieu Moy
matthieu@grenoble-inp.fr wrote:
 Christian Couder christian.cou...@gmail.com writes:

 In practice though, as git bisect is a kind of binary search, if what
 you want to exclude is exclusively touched by half the commits, it
 will only add one more bisection step if you don't exclude it.

 Actually, I think the same remark would apply to any other Git command
 that deal with a set of revisions. If you want to review code with git
 log -p, but you don't care about a subdirectory, you may want a git
 log -p --ignore-dir foo/ or so, too.

Yeah, and there was a patch series about that 2 years ago:

http://thread.gmane.org/gmane.comp.version-control.git/182830/

 And then, the it's logarithmic argument doesn't work anymore ;-).

Sure.

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: GSoC 2014: Summary so far, discussion starter: how to improve?

2013-10-19 Thread Christian Couder
Hi,

On Sat, Oct 19, 2013 at 8:09 AM, Thomas Rast t...@thomasrast.ch wrote:

 Previous Episodes
 =

 Git participated in Google Summer of Code (GSoC) 2007-2012, but did not
 participate in 2013 based on discussion in February [1].  At Git-Merge
 in Berlin there was a discussion round [2] that this post attempts to
 summarize as a basis for further discussion and (hopefully)
 participation in GSoC'14.

 Much sooner than in previous years, Google has already confirmed that
 GSoC'14 will in fact happen [3].

 Note that while mistakes herein are mine, many ideas and opinions
 aren't.  This really tries to be a summary.  Please flame /dev/null,
 not me.

Thank you for sending this very good summary.

 Theories
 

 These are the hypotheses that I have heard (mostly in [1] and [2]) as
 to what is bad about Git's prior GSoC participations.

 * Aiming far too high, focusing on cool/shiny projects with a large
   impact.  This also affects the students, who tend to cluster around
   the largest, shiniest project suggestions.

Yeah, focusing on _too big_ projects.

 * Diminishing returns: Git is too mature, with little low-hanging
   fruit left, making such projects harder

 * Projects are too political, progress depending on non-technical
   arguments

 * Our mentors suck on various axes, notably not supporting students
   enough in things that matter:
   - smooth interaction with community
   - ensure fast iteration/short cycles
   - navigating the code base

Yeah, fast iteration/short cycles means submitting the work early
and often _to the mailing list_.

One of the thing we learned too is that focusing on selecting the
best students didn't really worked.
What worked was selecting students who have already contributed
patches, but unfortunately there are not many potential students who
have already contributed.

 Further steps
 =

 * Discuss :-)

   And then apply this hard-won knowledge systematically.  In
   particular I think it wouldn't hurt to keep the project proposals
   out of this thread until we have agreed on goals/standards to
   measure them against.

Based on the above, what about the following:

1) Advertise early and widely that we will very strongly favor
students who have already contributed and that we can help them
contribute long before their application process starts. Maybe we
could even have a pre GSoC application process for potential students.

2) Advertise that we will really favor small projects over big/shiny ones.

3) Come up with a list of criteria like the following to measure
student/application:

- has the student already contributed much: 0-30 points:
0 means no contribution to any open source project,
5 means some contribution to another open source project,
20 means long time Git contributor

- what is the size of the project: 0-10 points:
0 means big project (one month or more for a regular contributor)
10 means small project (one week for a regular contributor)

- does the student appear willing to act on advice: 0-5 points

- does the student appear to have the necessary skills: 0-5 points

- does the proposal look good: 0-5 points

 * Gather a list of potential mentors.

I would be happy to mentor next year.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] sha1_file: move comment about return value where it belongs

2013-10-26 Thread Christian Couder
Commit 5b0864070 (sha1_object_info_extended: make type calculation
optional, Jul 12 2013) changed the return value of the
sha1_object_info_extended function to 0/-1 for success/error.

Previously this function returned the object type for success or
-1 for error. But unfortunately the above commit forgot to change
or move the comment above this function that says returns enum
object_type or negative.

To fix this inconsistency, let's move the comment above the
sha1_object_info function where it is still true.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 sha1_file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sha1_file.c b/sha1_file.c
index f80bbe4..7dadd04 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2514,7 +2514,6 @@ static int sha1_loose_object_info(const unsigned char 
*sha1,
return 0;
 }
 
-/* returns enum object_type or negative */
 int sha1_object_info_extended(const unsigned char *sha1, struct object_info 
*oi)
 {
struct cached_object *co;
@@ -2563,6 +2562,7 @@ int sha1_object_info_extended(const unsigned char *sha1, 
struct object_info *oi)
return 0;
 }
 
+/* returns enum object_type or negative */
 int sha1_object_info(const unsigned char *sha1, unsigned long *sizep)
 {
enum object_type type;
-- 
1.8.4.rc1.28.ge2684af

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-10-27 Thread Christian Couder
[Sorry I already sent the reply below to Johan only instead of everyone.]

Hi Johan,

On Sun, Oct 27, 2013 at 11:59 AM, Johan Herland jo...@herland.net wrote:
 On Sun, Oct 27, 2013 at 10:20 AM, Josh Triplett j...@joshtriplett.org wrote:

 ...good suggestion:

 ~/src/linux$ git log --grep='stable@' --oneline --since='1 year ago' | wc -l
 2769
 ~/src/linux$ git log --grep='stable@' --oneline --since='1 year ago' 
 --pretty=format:%an | sort -u | wc -l
 839

 Several thousand commits per year by hundreds of unique people seems
 like enough to justify a short option.

 I think this can be solved just as well (if not better) using a
 combination of a commit message template (or a prepare-commit-msg
 hook) and a commit-msg hook.

Your suggestion is very good, and it is not incompatible with command
line options.
So both could be implemented and even work together.

For example if -f ack:Peff was passed to the command line, git commit could
lookup in the commit message template and see if there is one
RFC822-style header
that starts with or contains ack (discarding case) and it could look
in some previous commits if
there is an author whose name contains Peff (discarding case) and if
it is the case
it could append the following to the bottom of the commit message:

Fixes:
Reported-by:
Suggested-by:
Improved-by:
Acked-by: Jeff King p...@peff.net
Reviewed-by:
Tested-by:
Signed-off-by: Myself mys...@example.com

(I suppose that the sob is automatically added.)

It would work also with -f fix:security-bug and would put something
like what you suggested:

Fixes: 1234beef56 (Commit message summmary)

 Then, the commit-msg hook can clean up and transform this into the
 final commit message:

   My commit subject

   This is the commit message body.

   Fixes: 1234beef56 (Commit message summmary)
   Reported-by: Joe User j.u...@example.com
   Improved-by: Joe Hacker j.hac...@example.com
   Tested-by: Joe Tester j.tes...@example.com
   Signed-off-by: Myself mys...@example.com

 Here, the commit-msg hook removes the fields that were not filled in,
 and performs additional filtering on the Fixes line (Adding commit
 message summary). The filtering could also resolve ref names, so that
 if you had refs/tags/security-bug pointing at the buggy commit, then:

   Fixes: security-bug

 would be expanded/DWIMed into:

   Fixes: 1234beef56 (Commit message summmary)

 Obviously, any other fancy processing you want to do into in the
 commit-msg hook can be done as well, adding footnotes, checking that
 commits are present in the ancestry, etc, etc.

Yeah, the commit message hook could do some more processing if the
user adds or changes stuff.

 Three good reasons to go this way:

  1. If the user forgets to supply command-line options like -s,
 --fixes, etc, there is a nice reminder in the supplied form.

Great!

  2. No need to add any command-line options to Git.

This is not a good reason. If many users prefer a command line option,
why not let them use that?

  3. The whole mechanism is controlled by the project. The kernel folks
 can do whatever they want in their templates/hooks without needing
 changes to the Git project.

The Git project already manages sob lines. It would be a good thing if
it could manage
more of this stuff to help users in a generic way while taking care of
user preferences.

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-10-28 Thread Christian Couder
On Mon, Oct 28, 2013 at 10:08 AM, Junio C Hamano gits...@pobox.com wrote:

 Thinking aloud further, what I had in mind was along the lines of
 the following.

  * The most generic external interface would be spelled as

 --trailer token[=param]

where token can be things like signoff, closes, acked-by,
change-id, fixes, etc.; they can be taken from an unbounded
set.  The historical --signoff can become a short-hand for
--trailer signoff.  More than one --trailer option can be
given on a single command line.

Ok, and maybe the token could also be the full trailer like Signed-off-by.

  * The token is used to look into the configuration, e.g.,

[commitTrailer signoff]
 style = append-norepeat
 trailer = Signed-off-by
 command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

[commitTrailer change-id]
 style = append-only-if-missing
 trailer = Change-Id
 command = 'git hash-object -t commit --stdin $GIT_PROTO_COMMIT'

[commitTrailer fixes]
 style = overwrite
 trailer = Fixes
 command = 'git log -1 --oneline --format=%h (%s) --abbrev-commit=14 
 $ARG'

where

- commitTrailer.token.style defines the interaction with
  existing trailer of the same kind (e.g. S-o-b: accumulates by
  appending, but we try not to repeat the same sign-off twice
  which would show you forwarding your own message you are the
  last person in the Sign-off chain; Fixes: if there is already
  one will remove the old one and replaces; etc.);

- commitTrailer.token.trailer defines the trailer label at
  the beginning of the trailer line;

- commitTrailer.token.command gives the command to run to
  obtain the payload after the trailer label.  A handful
  obvious and useful variables are exported for the command to
  use, and param is exported as $ARG, if present.

 With the most generic syntax, with the above commitTrailer.fixes.*
 configuration, I would imagine that you can say something like:

 git commit --trailer fixes=v2.6.12^{/^i386: tweak frobnitz}

 to say that the first commit you find traversing the history of
 v2.6.12 whose title is i386: tweak frobnitz was faulty, and you
 are creating a commit that corrects its mistake.

 Giving some default configuration to often used trailer types
 (e.g. configuration for --trailer signoff) and promoting some
 commonly used ones into a separate built-in option (e.g. an option
 --signoff that does not have to say --trailer signoff) are
 entirely separate issues, and only time can nudge us into evaluating
 individual types of trailers.

Ok, and maybe, if there is no configuration for a trailer token, we
could look at the commit template.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-10-29 Thread Christian Couder
On Mon, Oct 28, 2013 at 3:46 AM, Johan Herland jo...@herland.net wrote:
 On Sun, Oct 27, 2013 at 8:04 PM, Christian Couder 
 christian.cou...@gmail.com wrote:

 If git commit processes these arguments and puts the result in the
 commit message file that is passed to the
 prepare-commit-msg hook, then this hook can still get them from the
 file and process them however it wants.

 And in most cases the processing could be the same as what is done by
 the commit-msg hook when the user changes the Fixes: xxx and
 Stuffed-by: yyy lines in the editor.

 So it would probably be easier for people customizing the
 prepare-commit-msg and commit-msg if git commit processes the
 arguments instead of just passing them to the prepare-commit-msg hook.

 And it will be better for people who don't set up any *commit-msg hook.
 Even if there is no commit template, -f Acked-by:Peff and -f
 Fixes:security-bug could still work.
 I suspect most users don't setup any hook or commit template.

 Hmm. I'm not sure what you argue about which part of the system should
 perform which function. Let's examine the above options in more
 detail. Roughly, the flow of events look like this

   git commit -f ack:Peff -f fix:security-bug
 |
 v
   builtin/commit.c (i.e. inside git commit)
 |
 v
   prepare-commit-msg hook
 |
 v
   commit message template:
 Fixes: security-bug
 Acked-by: Peff

Here it could already be:

 Fixes: 1234beef56 (Commit message summmary)
 Acked-by: Jeff King p...@peff.net

Because builtin/commit.c hook could already have expanded everything.

 |
 v
   user edits commit message (may or may not change Fixes/Acked-by lines)
 |
 v
   commit-msg hook
 |
 v
   commit message:
 Fixes: 1234beef56 (Commit message summmary)
 Acked-by: Jeff King p...@peff.net

 (The above is even a bit simplified, but I believe it's sufficient for
 the current discussion.) So, there are several expansions happening
 between the initial git commit and the final commit message. They
 are:

  1. fix - Fixes: 
  2. security-bug - 1234beef56 (Commit message summmary)
  3. ack - Acked-by: 
  4. Peff - Jeff King p...@peff.net

 First, I think we both agree that expansions #2 and #4 MUST be done by
 the commit-msg hook. The reason for this is two-fold: (a) the
 expansion must be done (at least) after the user has edited the commit
 message (since the values entered by the user might require the same
 expansion), and (b) how (and whether) to perform the expansion is a
 project-specific policy question, and not something that Git can
 dictate.

I don't agree. Git doesn't need to dictate anything to be able to do
these expansions.
Git only needs some hints to do these expansions properly and it could
just look at the commit template, or the config, to get those hints.

For example, if there is a Acked-by: line in the commit template,
then Git might decide that ack means Acked-by, and then that -by
means that Peff should be related to an author, and then that it is
probably Jeff King p...@peff.net.

 Obviously, common functionality can be made available in the
 default hook shipped by Git, but it's up to each project to enable
 and/or customize this.

 Second, there is #1 and #3, the expansion of ack - Acked-by: and
 fix - Fixes:. Is this expansion performed by the
 prepare-commit-msg hook, or directly inside builtin/commit.c?

 If you are arguing for the latter (and I'm not sure that you are), we
 would need to add a dictionary to git commit that maps shorthand
 field names (ack) to the RFC822 -style equivalent (Acked-by: ).

Yes, I am arguing that builtin/commit.c, or better a plumbing command
launched by builtin/commit.c, should do it.

And I don't think there is an absolute need for a dictionary.
There could be such a dictionary in the config (as Junio proposed).
But if there isn't, the plumbing command launched by builtin/commit.c
could look at the commit template to decide that ack means
Acked-by:.

 I would instead argue for the former, i.e. simply forwarding ack and
 fix as-is to the prepare-commit-msg hook, and let it deal with the
 appropriate expansion. The main reason for this is that if a project
 wants to add another shorthand expansion (e.g. bug -
 Related-Bugzilla-Id: ), they can do so without hacking
 builtin/commit.c.

I agree that there should be no need to hack builtin/commit.c.
For example if Bugzilla-Id: is in the commit template, the plumbing
command launched by builtin/commit.c would decide that bug means
Bugzilla-Id: without any hack.

Of course this suppose that there is no other Bugtracker: or Bug:
in the commit template.
But even in this case it would mean that users have to use -f
bugz:XXX (or --trailer bugz=XXX) instead of just -f bug:XXX.

 Supporting project specific conventions/rules would still be possible
 by processing lines in the commit message file without changing git
 commit.

 If git commit is already able to do some processing, it only adds

Re: [PATCH] commit: Add -f, --fixes commit option to add Fixes: line

2013-11-02 Thread Christian Couder
On Wed, Oct 30, 2013 at 8:07 PM, Johan Herland jo...@herland.net wrote:
 On Tue, Oct 29, 2013 at 7:23 AM, Christian Couder
 christian.cou...@gmail.com wrote:

 I don't agree. Git doesn't need to dictate anything to be able to do
 these expansions.
 Git only needs some hints to do these expansions properly and it could
 just look at the commit template, or the config, to get those hints.

 For example, if there is a Acked-by: line in the commit template,
 then Git might decide that ack means Acked-by, and then that -by
 means that Peff should be related to an author, and then that it is
 probably Jeff King p...@peff.net.

 I don't like putting that much Magic into core Git... Especially not
 into builtin/commit.c. However, if we - as you suggest further below -
 put it into a separate helper, and we make that helper available (and
 usable) from elsewhere (most importantly from hooks where
 people/projects can add their own more specific functionality), then I
 don't have a problem with it.

Ok, great! I started working on git interpret-trailers and I will
post an RFC patch soon.
It will support both configuration as Junio suggested and reading a
commit template file as you suggested.

 Ok, let's call the new plumbing command git interpret-trailers.
 And let's suppose that git commit is passed -f ack:Peff -f
 fix:security-bug (or --trailer ack=Peff --trailer
 fix=security-bug).

 git commit would then call something like:

 git interpret-trailers --file commit_message_template.txt 'ack:Peff'
 'fix:security-bug'

 And this command would output:

 --
 upper part of commit_message_template.txt

 Fixes: 1234beef56 (Commit message summmary)
 Reported-by:
 Suggested-by:
 Improved-by:
 Acked-by: Jeff King p...@peff.net
 Reviewed-by:
 Tested-by:
 Signed-off-by: Myself mys...@example.com
 --

 Because it would have looked at the commit template it is passed and
 filled in the blanks it could fill using the arguments it is also
 passed.

 git commit would then put the above lines in the file that it passes
 to the prepare-commit-msg hook.

 Then the prepare-commit-msg could just do nothing.

 After the user has edited the commit message, the commit-msg hook
 could just call:

 git interpret-trailers --trim-empty --file commit_message.txt

 so that what the user changed is interpreted again.

 For example if the user changed the Reviewed-by: line to
 Reviewed-by: Johan, then the output would be:

 --
 upper part of commit_message.txt

 Fixes: 1234beef56 (Commit message summmary)
 Acked-by: Jeff King p...@peff.net
 Reviewed-by: Johan Herland jo...@herland.net
 Signed-off-by: Myself mys...@example.com
 --

 And that would be the final commit message in most cases.

 This approach looks OK to me, as long as we make sure that this
 functionality is (a) optional, (b) flexible/reusable from hooks, and
 (c) not bound tightly to core Git (and AFAICS, your proposal is just
 that). As I said above, this stuff certainly does not belong in
 builtin/commit.c...

Ok, I think it will be very easy to do all with git interpret-trailers.

Best regards,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] builtin/remote: remove postfixcmp() and use suffixcmp() instead

2013-11-03 Thread Christian Couder
Commit 8cc5b290 (git merge -Xoption, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/remote.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 4e14891..9b3a98e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -80,14 +80,6 @@ static int verbose;
 static int show_all(void);
 static int prune_remote(const char *remote, int dry_run);
 
-static inline int postfixcmp(const char *string, const char *postfix)
-{
-   int len1 = strlen(string), len2 = strlen(postfix);
-   if (len1  len2)
-   return 1;
-   return strcmp(string + len1 - len2, postfix);
-}
-
 static int fetch_remote(const char *name)
 {
const char *argv[] = { fetch, name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!postfixcmp(key, .remote)) {
+   if (!suffixcmp(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!postfixcmp(key, .merge)) {
+   } else if (!suffixcmp(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!postfixcmp(key, .rebase)) {
+   } else if (!suffixcmp(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
-- 
1.8.4.1.576.g36ba827.dirty

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC/PATCH] Add interpret-trailers builtin

2013-11-03 Thread Christian Couder
This RFC patch shows the work in progress to implement a new
command:

git interpret-trailers

1) Rational:

This command should help with RFC 822 style headers, called
trailers, that are found at the end of commit messages.

For a long time, these trailers have become a de facto standard
way to add helpful information into commit messages.

Until now git commit has only supported the well known
Signed-off-by:  trailer, that is used by many projects like
the Linux kernel and Git.

It is better to implement features for these trailers in a new
command rather than in builtin/commit.c, because this way the
prepare-commit-msg and commit-msg hooks can reuse this command.

2) Current state:

Currently the usage string of this command is:

git interpret-trailers [--trim-empty] [--infile=file] [token[=value]...]

The following features are implemented:
- the result is printed on stdout
- the [token[=value]...] arguments are interpreted
- a commit message passed using the --infile=file option is 
interpreted
- the trailer.token.value options in the config are interpreted

The following features are planned but not yet implemented:
- some documentation
- more tests
- the trailer.token.if_exist config option
- the trailer.token.if_missing config option
- the trailer.token.command config option

3) Notes:

* trailer seems better than commitTrailer as the config key because
it looks like all the config keys are lower case and committrailer is not
very readable.

* trailer.token.value looks better than trailer.token.trailer, so
I chose the former.

* Rather than only one trailer.token.style config option, it seems
better to me to have both trailer.token.if_exist and
trailer.token.if_missing.

* I might send a patch series instead of just one big patch when there will
be fewer big changes in the code.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 .gitignore|   1 +
 Makefile  |   1 +
 builtin.h |   1 +
 builtin/interpret-trailers.c  | 284 ++
 git.c |   1 +
 strbuf.c  |   7 ++
 strbuf.h  |   1 +
 t/t7513-interpret-trailers.sh | 101 +++
 8 files changed, 397 insertions(+)
 create mode 100644 builtin/interpret-trailers.c
 create mode 100755 t/t7513-interpret-trailers.sh

diff --git a/.gitignore b/.gitignore
index 66199ed..e6cf15b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -73,6 +73,7 @@
 /git-index-pack
 /git-init
 /git-init-db
+/git-interpret-trailers
 /git-instaweb
 /git-log
 /git-lost-found
diff --git a/Makefile b/Makefile
index af847f8..96441f1 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,7 @@ BUILTIN_OBJS += builtin/hash-object.o
 BUILTIN_OBJS += builtin/help.o
 BUILTIN_OBJS += builtin/index-pack.o
 BUILTIN_OBJS += builtin/init-db.o
+BUILTIN_OBJS += builtin/interpret-trailers.o
 BUILTIN_OBJS += builtin/log.o
 BUILTIN_OBJS += builtin/ls-files.o
 BUILTIN_OBJS += builtin/ls-remote.o
diff --git a/builtin.h b/builtin.h
index b56cf07..88c2999 100644
--- a/builtin.h
+++ b/builtin.h
@@ -71,6 +71,7 @@ extern int cmd_hash_object(int argc, const char **argv, const 
char *prefix);
 extern int cmd_help(int argc, const char **argv, const char *prefix);
 extern int cmd_index_pack(int argc, const char **argv, const char *prefix);
 extern int cmd_init_db(int argc, const char **argv, const char *prefix);
+extern int cmd_interpret_trailers(int argc, const char **argv, const char 
*prefix);
 extern int cmd_log(int argc, const char **argv, const char *prefix);
 extern int cmd_log_reflog(int argc, const char **argv, const char *prefix);
 extern int cmd_ls_files(int argc, const char **argv, const char *prefix);
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
new file mode 100644
index 000..2bcd480
--- /dev/null
+++ b/builtin/interpret-trailers.c
@@ -0,0 +1,284 @@
+/*
+ * Builtin git interpret-trailers
+ *
+ * Copyright (c) 2013 Christian Couder chrisc...@tuxfamily.org
+ *
+ */
+
+#include cache.h
+#include builtin.h
+#include parse-options.h
+#include strbuf.h
+
+static const char * const git_interpret_trailers_usage[] = {
+   N_(git interpret-trailers [--trim-empty] [--infile=file] 
[token[=value]...]),
+   NULL
+};
+
+static void parse_arg(struct strbuf *tok, struct strbuf *val, const char *arg)
+{
+   char *end = strchr(arg, '=');
+   if (!end)
+   end = strchr(arg, ':');
+   if (end) {
+   strbuf_add(tok, arg, end - arg);
+   strbuf_trim(tok);
+   strbuf_addstr(val, end + 1);
+   strbuf_trim(val);
+   } else {
+   strbuf_addstr(tok, arg);
+   strbuf_trim(tok);
+   }
+}
+
+static struct string_list trailer_list;
+
+enum style_if_exist { DONT_REPEAT, OVERWRITE, REPEAT };
+enum style_if_missing { DONT_APPEND, APPEND

Re: [PATCH] builtin/remote: remove postfixcmp() and use suffixcmp() instead

2013-11-04 Thread Christian Couder
From: Junio C Hamano gits...@pobox.com
Subject: Re: [PATCH] builtin/remote: remove postfixcmp() and use suffixcmp() 
instead
Date: Mon, 04 Nov 2013 11:19:43 -0800

 Christian Couder chrisc...@tuxfamily.org writes:
 
 Commit 8cc5b290 (git merge -Xoption, 25 Nov 2009) introduced
 suffixcmp() with nearly the same implementation as postfixcmp()
 that already existed since commit 211c8968 (Make git-remote a
 builtin, 29 Feb 2008).
 
 This nearly the same piqued my curiosity ;-)

Yeah, I realize I should have explained the differences.
 
 The postfixcmp() you are removing will say f  .txt while
 suffixcmp() will say f  .txt.
 
 As postfixcmp() is only used to compare for equality, the
 distinction does not matter and does not affect the correctness of
 this patch, but I am not sure which answer is more correct.

Yeah, that's also my opinion. I am not even sure if there is one more
correct answer than the other.

 I do not think anybody sane uses prefixcmp() or suffixcmp() for
 anything but checking with zero; in other words, I suspect that all
 uses of Xcmp() can be replaced with !!Xcmp(), so as a separate
 clean-up patch, we may at least want to make it clear that the
 callers should not expect anything but does str have sfx as its
 suffix, yes or no? by doing something like this:
 
  int suffixcmp(const char *str, const char *suffix)
  {
   int len = strlen(str), suflen = strlen(suffix);
   if (len  suflen)
   return -1;
   else
 - return strcmp(str + len - suflen, suffix);
 + return !!strcmp(str + len - suflen, suffix);
  }
 
 I am not absolutely sure about doing the same to prefixcmp(),
 though. It could be used for ordering, even though no existing code
 seems to do so.

I agree.

I will resend a 2 patch long patch series where the first patch will
have an improved commit message and the second patch will do what you suggest 
above.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] builtin/remote: remove postfixcmp() and use suffixcmp() instead

2013-11-04 Thread Christian Couder
Commit 8cc5b290 (git merge -Xoption, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

The only difference between the two implementations is that,
when the string is smaller than the suffix, one implementation
returns 1 while the other one returns -1.

But, as postfixcmp() is only used to compare for equality, the
distinction does not matter and does not affect the correctness of
this patch.

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Reviewed-by: Jonathan Nieder jrnie...@gmail.com
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/remote.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 4e14891..9b3a98e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -80,14 +80,6 @@ static int verbose;
 static int show_all(void);
 static int prune_remote(const char *remote, int dry_run);
 
-static inline int postfixcmp(const char *string, const char *postfix)
-{
-   int len1 = strlen(string), len2 = strlen(postfix);
-   if (len1  len2)
-   return 1;
-   return strcmp(string + len1 - len2, postfix);
-}
-
 static int fetch_remote(const char *name)
 {
const char *argv[] = { fetch, name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!postfixcmp(key, .remote)) {
+   if (!suffixcmp(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!postfixcmp(key, .merge)) {
+   } else if (!suffixcmp(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!postfixcmp(key, .rebase)) {
+   } else if (!suffixcmp(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
-- 
1.8.4.1.576.g36ba827.dirty


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] strbuf: make it clear that suffixcmp() should not be used for sorting

2013-11-04 Thread Christian Couder
Nobody sane uses suffixcmp() for anything but checking with zero,
but it is not very clear from the implementation that it should
not be used for any sorting.

So let's make it clear that the callers should not expect anything
but does str have sfx as its suffix, yes or no?.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 strbuf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/strbuf.c b/strbuf.c
index 1170d01..9ba50de 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -16,7 +16,7 @@ int suffixcmp(const char *str, const char *suffix)
if (len  suflen)
return -1;
else
-   return strcmp(str + len - suflen, suffix);
+   return !!strcmp(str + len - suflen, suffix);
 }
 
 /*
-- 
1.8.4.1.576.g36ba827.dirty

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Rename suffixcmp() to has_suffix()

2013-11-04 Thread Christian Couder
As suffixcmp() should not be used as an ordering comparison function,
and anything-cmp() ought to be usable as an ordering comparison function,
suffixcmp() should be renamed to something that doesn't end with cmp.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi Junio,

This is a patch, following your last suggestion, that should be added or
squashed into the 2 patch series I sent one hour ago.

Thanks,
Christian.

 builtin/clone.c   | 2 +-
 builtin/fetch.c   | 2 +-
 builtin/merge-recursive.c | 2 +-
 builtin/remote.c  | 6 +++---
 builtin/repack.c  | 2 +-
 connected.c   | 2 +-
 git-compat-util.h | 2 +-
 strbuf.c  | 2 +-
 8 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 874e0fd..4b8308e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -510,7 +510,7 @@ static void write_followtags(const struct ref *refs, const 
char *msg)
for (ref = refs; ref; ref = ref-next) {
if (prefixcmp(ref-name, refs/tags/))
continue;
-   if (!suffixcmp(ref-name, ^{}))
+   if (!has_suffix(ref-name, ^{}))
continue;
if (!has_sha1_file(ref-old_sha1))
continue;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index bd7a101..a26b0e5 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -653,7 +653,7 @@ static void find_non_local_tags(struct transport *transport,
 * to fetch then we can mark the ref entry in the list
 * as one to ignore by setting util to NULL.
 */
-   if (!suffixcmp(ref-name, ^{})) {
+   if (!has_suffix(ref-name, ^{})) {
if (item  !has_sha1_file(ref-old_sha1) 
!will_fetch(head, ref-old_sha1) 
!has_sha1_file(item-util) 
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 3a64f5d..6ba30aa 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -29,7 +29,7 @@ int cmd_merge_recursive(int argc, const char **argv, const 
char *prefix)
struct commit *result;
 
init_merge_options(o);
-   if (argv[0]  !suffixcmp(argv[0], -subtree))
+   if (argv[0]  !has_suffix(argv[0], -subtree))
o.subtree_shift = ;
 
if (argc  4)
diff --git a/builtin/remote.c b/builtin/remote.c
index 9b3a98e..c04fd7d 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -269,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!suffixcmp(key, .remote)) {
+   if (!has_suffix(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!suffixcmp(key, .merge)) {
+   } else if (!has_suffix(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!suffixcmp(key, .rebase)) {
+   } else if (!has_suffix(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
diff --git a/builtin/repack.c b/builtin/repack.c
index a0ff5c7..79b14bf 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -78,7 +78,7 @@ static void get_non_kept_pack_filenames(struct string_list 
*fname_list)
return;
 
while ((e = readdir(dir)) != NULL) {
-   if (suffixcmp(e-d_name, .pack))
+   if (has_suffix(e-d_name, .pack))
continue;
 
len = strlen(e-d_name) - strlen(.pack);
diff --git a/connected.c b/connected.c
index fae8d64..6a1629c 100644
--- a/connected.c
+++ b/connected.c
@@ -38,7 +38,7 @@ int check_everything_connected_with_transport(sha1_iterate_fn 
fn,
if (transport  transport-smart_options 
transport-smart_options-self_contained_and_connected 
transport-pack_lockfile 
-   !suffixcmp(transport-pack_lockfile, .keep)) {
+   !has_suffix(transport-pack_lockfile, .keep)) {
struct strbuf idx_file = STRBUF_INIT;
strbuf_addstr(idx_file, transport-pack_lockfile);
strbuf_setlen(idx_file, idx_file.len - 5); /* .keep */
diff --git a/git-compat-util.h b/git-compat-util.h
index 7776f12..0f6a31e 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -351,7 +351,7 @@ extern void set_error_routine(void (*routine)(const char 
*err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int prefixcmp(const char *str, const char *prefix);
-extern int suffixcmp(const char *str, const char *suffix);
+extern int has_suffix(const char *str, const char *suffix

[PATCH v2] Rename suffixcmp() to has_suffix() and inverse its result

2013-11-04 Thread Christian Couder
As suffixcmp() should not be used as an ordering comparison function,
and anything-cmp() ought to be usable as an ordering comparison function,
suffixcmp() should be renamed to something that doesn't end with cmp.

has_suffix() is a straightforward name for such a function, except
that with such a name callers will expect that it will return 1
when the suffix is present and 0 otherwise.

So we need to also inverse the value returned by this function to
match what the callers will expect, because suffixcmp() like all
anything-cmp() returns 0 when the suffix is present and 1 or -1
otherwise.

As we inverse the value returned by the function, we also have
to inverse the ways its callers are using its returned value.

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi Junio and Peff,

So here is a new version of the patch to rename
suffixcmp() into has_suffix(). We now inverse the
result of the function as we rename it.

This patch should be added to or squashed into the
patch series that removes postfixcmp().

Thanks,
Christian.

 builtin/clone.c   | 2 +-
 builtin/fetch.c   | 2 +-
 builtin/merge-recursive.c | 2 +-
 builtin/remote.c  | 6 +++---
 builtin/repack.c  | 2 +-
 connected.c   | 2 +-
 git-compat-util.h | 2 +-
 strbuf.c  | 6 +++---
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 874e0fd..84fb1bd 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -510,7 +510,7 @@ static void write_followtags(const struct ref *refs, const 
char *msg)
for (ref = refs; ref; ref = ref-next) {
if (prefixcmp(ref-name, refs/tags/))
continue;
-   if (!suffixcmp(ref-name, ^{}))
+   if (has_suffix(ref-name, ^{}))
continue;
if (!has_sha1_file(ref-old_sha1))
continue;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index bd7a101..8eb6cd0 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -653,7 +653,7 @@ static void find_non_local_tags(struct transport *transport,
 * to fetch then we can mark the ref entry in the list
 * as one to ignore by setting util to NULL.
 */
-   if (!suffixcmp(ref-name, ^{})) {
+   if (has_suffix(ref-name, ^{})) {
if (item  !has_sha1_file(ref-old_sha1) 
!will_fetch(head, ref-old_sha1) 
!has_sha1_file(item-util) 
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 3a64f5d..e7f1a39 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -29,7 +29,7 @@ int cmd_merge_recursive(int argc, const char **argv, const 
char *prefix)
struct commit *result;
 
init_merge_options(o);
-   if (argv[0]  !suffixcmp(argv[0], -subtree))
+   if (argv[0]  has_suffix(argv[0], -subtree))
o.subtree_shift = ;
 
if (argc  4)
diff --git a/builtin/remote.c b/builtin/remote.c
index 9b3a98e..b9a1024 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -269,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!suffixcmp(key, .remote)) {
+   if (has_suffix(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!suffixcmp(key, .merge)) {
+   } else if (has_suffix(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!suffixcmp(key, .rebase)) {
+   } else if (has_suffix(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
diff --git a/builtin/repack.c b/builtin/repack.c
index a0ff5c7..9ef518d 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -78,7 +78,7 @@ static void get_non_kept_pack_filenames(struct string_list 
*fname_list)
return;
 
while ((e = readdir(dir)) != NULL) {
-   if (suffixcmp(e-d_name, .pack))
+   if (!has_suffix(e-d_name, .pack))
continue;
 
len = strlen(e-d_name) - strlen(.pack);
diff --git a/connected.c b/connected.c
index fae8d64..be9304e 100644
--- a/connected.c
+++ b/connected.c
@@ -38,7 +38,7 @@ int check_everything_connected_with_transport(sha1_iterate_fn 
fn,
if (transport  transport-smart_options 
transport-smart_options-self_contained_and_connected 
transport-pack_lockfile 
-   !suffixcmp(transport-pack_lockfile, .keep)) {
+   has_suffix(transport-pack_lockfile, .keep)) {
struct strbuf idx_file = STRBUF_INIT

Re: [RFC/PATCH] Add interpret-trailers builtin

2013-11-04 Thread Christian Couder
From: Johan Herland jo...@herland.net
 On Mon, Nov 4, 2013 at 8:12 PM, Junio C Hamano gits...@pobox.com wrote:
 Johan Herland jo...@herland.net writes:
 +{
 +   char *end = strchr(arg, '=');
 +   if (!end)
 +   end = strchr(arg, ':');

 So both '=' (preferred) and ':' are accepted as field/value
 separators. That's ok for the command-line, I believe.

 Why?

 Sometimes you have to be loose from the beginning _if_ some existing
 uses and established conventions make it easier for the users,

The users are already used to appending Acked-by: Joe j...@example.com.
So I think it makes it easier for the user to accept what they are already
used to provide.

 but
 if you do not have to start from being loose, it is almost always a
 mistake to do so.  The above code just closed the door to use :
 for some other useful purposes we may later discover, and will make
 us regret for doing so.
 
 Although I agree with the principle, I think there are (at least) two
 established conventions that will be commonly used from the start, and
 that we should support:
 
  - Using short forms with '=', e.g. ack=Peff. There is already a
 convention on how we specify name + value pairs on the command
 line, e.g. git -c foo=bar ...
 
  - Copy-pasting footers from existing commit messages. These will have
 the same format as the expected output of this command, and not
 accepting the same format in its input seems silly, IMHO.

I agree. Also I think it will avoid some mistakes by the users.
Because it would require an effort for them to remember that if they
want to see Acked-by: Joe j...@example.com they have to put
Acked-by= Joe j...@example.com on the command line.

 That said, I think this applies only to the formatting on the _command
 line_.

But wouldn't it be nice if the same parsing function could be used for
both the command line and the commit message template?

 When it comes to how the resulting footers are formatted in the
 commit message, I would argue it only makes sense to use ':', and I
 think the testcase named 'with config setup and = sign' in the above
 patch is ugly and unnecessary.

I wanted to support configurations like this:

[trailer ack]
value = Acked-by= 
[trailer bug]
value = Bug # 

because Peff said that GitHub uses '#' and while at it I suppose some
people might prefer '=' over ':'.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/2] Rename suffixcmp() to has_suffix() and invert its result

2013-11-05 Thread Christian Couder
Now has_suffix() returns 1 when the suffix is present and 0 otherwise.

The old name followed the pattern anything-cmp(), which suggests
a general comparison function suitable for e.g. sorting objects.
But this was not the case for suffixcmp().

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/clone.c   | 2 +-
 builtin/fetch.c   | 2 +-
 builtin/merge-recursive.c | 2 +-
 builtin/remote.c  | 6 +++---
 builtin/repack.c  | 2 +-
 connected.c   | 2 +-
 git-compat-util.h | 2 +-
 strbuf.c  | 6 +++---
 8 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 874e0fd..84fb1bd 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -510,7 +510,7 @@ static void write_followtags(const struct ref *refs, const 
char *msg)
for (ref = refs; ref; ref = ref-next) {
if (prefixcmp(ref-name, refs/tags/))
continue;
-   if (!suffixcmp(ref-name, ^{}))
+   if (has_suffix(ref-name, ^{}))
continue;
if (!has_sha1_file(ref-old_sha1))
continue;
diff --git a/builtin/fetch.c b/builtin/fetch.c
index bd7a101..8eb6cd0 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -653,7 +653,7 @@ static void find_non_local_tags(struct transport *transport,
 * to fetch then we can mark the ref entry in the list
 * as one to ignore by setting util to NULL.
 */
-   if (!suffixcmp(ref-name, ^{})) {
+   if (has_suffix(ref-name, ^{})) {
if (item  !has_sha1_file(ref-old_sha1) 
!will_fetch(head, ref-old_sha1) 
!has_sha1_file(item-util) 
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 3a64f5d..e7f1a39 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -29,7 +29,7 @@ int cmd_merge_recursive(int argc, const char **argv, const 
char *prefix)
struct commit *result;
 
init_merge_options(o);
-   if (argv[0]  !suffixcmp(argv[0], -subtree))
+   if (argv[0]  has_suffix(argv[0], -subtree))
o.subtree_shift = ;
 
if (argc  4)
diff --git a/builtin/remote.c b/builtin/remote.c
index 9b3a98e..b9a1024 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -269,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!suffixcmp(key, .remote)) {
+   if (has_suffix(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!suffixcmp(key, .merge)) {
+   } else if (has_suffix(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!suffixcmp(key, .rebase)) {
+   } else if (has_suffix(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
diff --git a/builtin/repack.c b/builtin/repack.c
index a0ff5c7..9ef518d 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -78,7 +78,7 @@ static void get_non_kept_pack_filenames(struct string_list 
*fname_list)
return;
 
while ((e = readdir(dir)) != NULL) {
-   if (suffixcmp(e-d_name, .pack))
+   if (!has_suffix(e-d_name, .pack))
continue;
 
len = strlen(e-d_name) - strlen(.pack);
diff --git a/connected.c b/connected.c
index fae8d64..be9304e 100644
--- a/connected.c
+++ b/connected.c
@@ -38,7 +38,7 @@ int check_everything_connected_with_transport(sha1_iterate_fn 
fn,
if (transport  transport-smart_options 
transport-smart_options-self_contained_and_connected 
transport-pack_lockfile 
-   !suffixcmp(transport-pack_lockfile, .keep)) {
+   has_suffix(transport-pack_lockfile, .keep)) {
struct strbuf idx_file = STRBUF_INIT;
strbuf_addstr(idx_file, transport-pack_lockfile);
strbuf_setlen(idx_file, idx_file.len - 5); /* .keep */
diff --git a/git-compat-util.h b/git-compat-util.h
index 7776f12..0f6a31e 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -351,7 +351,7 @@ extern void set_error_routine(void (*routine)(const char 
*err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int prefixcmp(const char *str, const char *prefix);
-extern int suffixcmp(const char *str, const char *suffix);
+extern int has_suffix(const char *str, const char *suffix);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
 {
diff --git a/strbuf.c b/strbuf.c
index 1170d01

[PATCH v3 1/2] builtin/remote: remove postfixcmp() and use suffixcmp() instead

2013-11-05 Thread Christian Couder
Commit 8cc5b290 (git merge -Xoption, 25 Nov 2009) introduced
suffixcmp() with nearly the same implementation as postfixcmp()
that already existed since commit 211c8968 (Make git-remote a
builtin, 29 Feb 2008).

The only difference between the two implementations is that,
when the string is smaller than the suffix, one implementation
returns 1 while the other one returns -1.

But, as postfixcmp() is only used to compare for equality, the
distinction does not matter and does not affect the correctness of
this patch.

As postfixcmp() has always been static in builtin/remote.c
and is used nowhere else, it makes more sense to remove it
and use suffixcmp() instead in builtin/remote.c, rather than
to remove suffixcmp().

Reviewed-by: Jonathan Nieder jrnie...@gmail.com
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
Hi everyone,

Here is another version of the series.
The first patch did not change.
The second patch has been changed according to the latest
suggestions by Max Horn and Junio.

Thanks,
Christian.

 builtin/remote.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/builtin/remote.c b/builtin/remote.c
index 4e14891..9b3a98e 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -80,14 +80,6 @@ static int verbose;
 static int show_all(void);
 static int prune_remote(const char *remote, int dry_run);
 
-static inline int postfixcmp(const char *string, const char *postfix)
-{
-   int len1 = strlen(string), len2 = strlen(postfix);
-   if (len1  len2)
-   return 1;
-   return strcmp(string + len1 - len2, postfix);
-}
-
 static int fetch_remote(const char *name)
 {
const char *argv[] = { fetch, name, NULL, NULL };
@@ -277,13 +269,13 @@ static int config_read_branches(const char *key, const 
char *value, void *cb)
enum { REMOTE, MERGE, REBASE } type;
 
key += 7;
-   if (!postfixcmp(key, .remote)) {
+   if (!suffixcmp(key, .remote)) {
name = xstrndup(key, strlen(key) - 7);
type = REMOTE;
-   } else if (!postfixcmp(key, .merge)) {
+   } else if (!suffixcmp(key, .merge)) {
name = xstrndup(key, strlen(key) - 6);
type = MERGE;
-   } else if (!postfixcmp(key, .rebase)) {
+   } else if (!suffixcmp(key, .rebase)) {
name = xstrndup(key, strlen(key) - 7);
type = REBASE;
} else
-- 
1.8.4.1.561.g186b3da.dirty


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH] Add interpret-trailers builtin

2013-11-05 Thread Christian Couder
From: Junio C Hamano gits...@pobox.com
 Christian Couder chrisc...@tuxfamily.org writes:

 * trailer seems better than commitTrailer as the config key because
 it looks like all the config keys are lower case and committrailer is not
 very readable.
 
 And closes the door for other things from later acquiring trailers?

I don't think it really closes the door, as they can have a name like
stufftrailer then. Or better they could call it something else than
trailer everywhere from the beginning to avoid mistakes in the first
place.

Or if they are really trailers, for example maybe tag trailers, then
in many cases they might want to share the same configuration as
commit trailers. In this case, it would be a mistake to use
commitTrailer when most people would like them to also apply to
tags.

If/when tag trailers appear, then we can decide that trailer  is
common for all trailers, commitTrailer is for commits only and
tagTrailer for tags only.

And anyway commit trailers have existed since the beginning or nearly
the beginning of Git, and we haven't seen yet any other kind of
trailer, so it's reasonnable to think that we can safely take the name
and not worry, be happy.

 * trailer.token.value looks better than trailer.token.trailer, so
 I chose the former.
 
 If that is a literal value, then I think .value is indeed good.

That was what I thought first too.

But, after thinking about what Johan said, I think that it might be
confusing for some people, so now I wonder if I should call it key.

 * Rather than only one trailer.token.style config option, it seems
 better to me to have both trailer.token.if_exist and
 trailer.token.if_missing.
 
 As there is no .if_exist, .if_missing, etc. here, I cannot guess
 what these seemingly independent and orthogonal, but some
 combinations are impossible configuration variables are meant to be
 used, let alone agreeing to the above claim that they are better
 than a single .style.

Yeah, I should have explained more. So I will do it now.

In the code I used the following enums:

enum style_if_exist { DONT_REPEAT, OVERWRITE, REPEAT };
enum style_if_missing { DONT_APPEND, APPEND };

The style_if_exist enum is meant to decide what is done when we have
to deal with 2 or more trailers, from the infile or the command line,
that have the same key but different not empty values.

For example, me might have the 3 following trailers:

Acked-by: joe joe@example
Acked-by: bob bob@example
Acked-by: joe joe@example

- The DONT_REPEAT style, which should be the default in my opinion,
would mean that we don't repeat the same values. So we would get:

Acked-by: joe joe@example
Acked-by: bob bob@example

- The OVERWRITE style would mean that we keep only one, (for example
the last one). So we would get:

Acked-by: joe joe@example

- The REPEAT style would mean that we keep everything. So we would
get:

Acked-by: joe joe@example
Acked-by: bob bob@example
Acked-by: joe joe@example

The style_if_missing enum is meant to decide what is done when we have
no trailer with the specified key. Then DONT_APPEND means that we do
nothing, which should be the default, and APPEND means that we append
a trailer with the specified key.

Of course in the latter case, a command should probably be specified
to tell which value should be used with the key.

For example:

[trailer signoff]
 key = Signed-off-by:
 if_missing = append
 command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

would append a s-o-b line only if there is no s-o-b already. 

Note that to always append a specific trailer one could use:

[trailer signoff]
 key = Signed-off-by:
 if_missing = append
 if_exist = repeat
 command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

 I think you took the .style from my
 thinking-aloud message the other day, but that aloud-thinking lead
 to .style by taking various use cases people wanted to have
 footers into account, including:

Ok, I will try to guess below, how the use cases could be configured.

  - just appending, allowing duplication of the field name (e.g. more
than one cc: can name different recipients);

That would be the default (if_exist = dont_repeat, if_missing = dont_append).

  - appending, allowing duplication of the field name,val pair
(e.g. a patch that flowed from person A to B and possibly
somewhere else then finally back to A may have Signed-off-by:
A, chain of other's Sob, and another Signed-off-by: A);

That would be: if_exist = repeat, if_missing = dont_append

  - appending, but without consecutive repeats (e.g. the same
Signed-off-by: example; person A does not pass a patch to
himself, adding two same name,val pair next to each other);

I could add a DONT_REPEAT_PREVIOUS into the style_if_exist enum, for
this case.

Then that would be: if_exist = dont_repeat_previous, if_missing = dont_append

  - adding only if there is no same name (e.g. Change-Id:);

I could add a DONT_APPEND

Re: [RFC/PATCH] Add interpret-trailers builtin

2013-11-06 Thread Christian Couder
On Wed, Nov 6, 2013 at 7:43 AM, Christian Couder
chrisc...@tuxfamily.org wrote:
 Of course in the latter case, a command should probably be specified
 to tell which value should be used with the key.

 For example:

 [trailer signoff]
  key = Signed-off-by:
  if_missing = append
  command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

 would append a s-o-b line only if there is no s-o-b already.

Sorry, I realize that I was wrong above.
As the default for if_exist is dont_repeat, the above would append
a s-o-b if there is no s-o-b or if there is one but with a different
value.

To append a s-o-b only if there is no s-o-b already, one would need to use:

[trailer signoff]
 key = Signed-off-by:
 if_exist = dont_append
 if_missing = append
 command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH] Add interpret-trailers builtin

2013-11-06 Thread Christian Couder
From: Junio C Hamano gits...@pobox.com

 Christian Couder christian.cou...@gmail.com writes:
 
 To append a s-o-b only if there is no s-o-b already, one would need to use:

 [trailer signoff]
  key = Signed-off-by:
  if_exist = dont_append
  if_missing = append
  command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'
 
 But that is insufficient to emulate what we do, no?  I.e. append
 unless the last one is from the same person we are about to add.

Yeah, but, with DONT_REPEAT_PREVIOUS, it would be possible using:

[trailer signoff]
 key = Signed-off-by:
 if_exist = dont_repeat_previous
 if_missing = append
 command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

Cheers,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [ANNOUNCE] Git v1.8.5-rc1

2013-11-07 Thread Christian Couder
On Thu, Nov 7, 2013 at 12:57 AM, Junio C Hamano gits...@pobox.com wrote:

  * git replace helper no longer allows an object to be replaced with
another object of a different type to avoid confusion (you can
still manually craft such replacement using git update-ref, as an
escape hatch).

Maybe it would be more helpful to say you can still do that using the
--force option instead of pointing people to git update-ref.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/2] Rename suffixcmp() to has_suffix() and invert its result

2013-11-07 Thread Christian Couder
On Thu, Nov 7, 2013 at 1:12 AM, Junio C Hamano gits...@pobox.com wrote:
 Jonathan Nieder jrnie...@gmail.com writes:

 The old name followed the pattern anything-cmp(), which suggests
 a general comparison function suitable for e.g. sorting objects.
 But this was not the case for suffixcmp().

 It's not clear to me that prefixcmp() is usable for sorting objects,
 either.  Shouldn't it get the same treatment?

 Sounds like a plan for a good follow-up series.

Ok, I will have a look.

 If some day we invent a type for 4-byte-aligned object names, it might
 make sense to do something similar to hashcmp, distinguishing between
 hashcmp for use where ordering is important and something like hash_eq
 when checking for equality (since I suspect the latter can be made
 faster).

 Interesting.

Yeah, but I will pass on this one.

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC/PATCH] Add interpret-trailers builtin

2013-11-07 Thread Christian Couder
On Wed, Nov 6, 2013 at 9:42 PM, Junio C Hamano gits...@pobox.com wrote:
 Christian Couder chrisc...@tuxfamily.org writes:
 From: Junio C Hamano gits...@pobox.com

 But that is insufficient to emulate what we do, no?  I.e. append
 unless the last one is from the same person we are about to add.

 Yeah, but, with DONT_REPEAT_PREVIOUS, it would be possible using:

 [trailer signoff]
  key = Signed-off-by:
  if_exist = dont_repeat_previous
  if_missing = append
  command = echo $GIT_COMMITTER_NAME $GIT_COMMITTER_EMAIL'

 Anything is possible, but possible does not justify it is better
 way than other possible ways.

 What are the plausible values for if_missing?  If if_missing needs
 prepend, for example, in addition to append, does it mean
 if_exist also needs corresponding prepend variant for the value
 dont_repeat_previous you would give to if_exist?

Yeah, we could add prepend to the possible values for if_missing and
also other values that prepend instead of append to if_exist.
But I am not sure they would be as useful.

If we think they are useful, then maybe we could instead add another
configuration to say if we want to append or prepend or put in the
middle, and change the others to make them clearer.
For example we could have:

where = (after | middle | before)
if_exist = (add_if_different | add_if_neighbor_different | add |
overwrite | do_nothing)
if_missing = (do_nothing | add)

(The default being the first choice.)

 Having two that are seemingly independent configuration does not
 seem to be helping in reducing complexity (by keeping settings that
 can be independently set orthogonal, by saying if the other rule
 decides to add, do we append, prepend, insert at the middle?, for
 example).

I am not sure I understand what you mean.
In my opinion, if we want to use just one configuration, instead of 2
or 3, it will not reduce complexity.

Maybe we could parse something like:

style = if_exist:add_if_different:after, if_missing:add:before

or like:

style = (append | prepend | insert | append_unless regexp |
prepend_unless regexp | insert_unless regexp)

with regexp being a regexp where $KEY is the key and $VALUE is the
value, so you can say: append_unless ^$KEY[:=]$VALUE.*

or like:

style = (append_if cmd | prepend_if cmd | insert_if cmd)

with cmd being a shell command that should exit with code 0.

(The command would be passed the existing trailers in stdin.
So you could say things like: append_if true or append_if tail -1 |
grep -v '$KEY: $VALUE')

But if we want to keep things simple, I think what I suggest first
above is probably best.

And by the way, later we might add add_if_match regexp or
add_if_true cmd to if_exist and if_missing, so we could still
be as powerful as the other styles.

 How would one differentiate between there is a field with that key
 and there is a field with that key, value combination with a
 single if_exist?  Add another variable if_exist_exact?

if_exist = do_nothing would mean: do nothing if there is a field
with that key
if_exist = overwrite would mean: overwrite the existing value of a
field with that key
if_exist = add would mean: add if there is one or more fields with
that key (whatever the value(s), so the value(s) could be the same)
if_exist = add_if_different would mean: add only if there is no
field with the same key, value pair
if_exist = add_if_different_neighbor would mean: add only if there
is no field with the same key, value pair where we are going to add

if_missing = do_nothing would mean: do nothing if there is no field
with that key
if_missing= add would mean: add if there is no field with that key

where = after would mean: if we decide to add, we will put the
trailer after the other trailers
where = middle would mean: if we decide to add, we will put the
trailer in the middle of the other trailers
where = before would mean: if we decide to add, we will put the
trailer before the other trailers

In my opinion, that should be enough for most use cases.

It is true that some people might want something more complex (like
adding only if there is no value for the same key that match a given
regexp) or something stranger like adding only if there is already a
field with the same key, value pair.

But we can take care of these special cases later if they actually happen.
Then we will hopefully have more experience.
And we could add things like add_if_no_value_match regexp or
add_if cmd to if_exist and if_missing .

Thanks,
Christian.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 20/86] http: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 http.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/http.c b/http.c
index f3e1439..f2621cd 100644
--- a/http.c
+++ b/http.c
@@ -422,7 +422,7 @@ void http_init(struct remote *remote, const char *url, int 
proactive_auth)
credential_from_url(http_auth, url);
if (!ssl_cert_password_required 
getenv(GIT_SSL_CERT_PASSWORD_PROTECTED) 
-   !prefixcmp(url, https://;))
+   has_prefix(url, https://;))
ssl_cert_password_required = 1;
}
 
@@ -985,7 +985,7 @@ int http_fetch_ref(const char *base, struct ref *ref)
strbuf_rtrim(buffer);
if (buffer.len == 40)
ret = get_sha1_hex(buffer.buf, ref-old_sha1);
-   else if (!prefixcmp(buffer.buf, ref: )) {
+   else if (has_prefix(buffer.buf, ref: )) {
ref-symref = xstrdup(buffer.buf + 5);
ret = 0;
}
@@ -1084,8 +1084,8 @@ int http_get_info_packs(const char *base_url, struct 
packed_git **packs_head)
case 'P':
i++;
if (i + 52 = buf.len 
-   !prefixcmp(data + i,  pack-) 
-   !prefixcmp(data + i + 46, .pack\n)) {
+   has_prefix(data + i,  pack-) 
+   has_prefix(data + i + 46, .pack\n)) {
get_sha1_hex(data + i + 6, sha1);
fetch_and_setup_pack_index(packs_head, sha1,
  base_url);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 23/86] log-tree: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 log-tree.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/log-tree.c b/log-tree.c
index 8534d91..25b46a9 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -98,7 +98,7 @@ static int add_ref_decoration(const char *refname, const 
unsigned char *sha1, in
struct object *obj;
enum decoration_type type = DECORATION_NONE;
 
-   if (!prefixcmp(refname, refs/replace/)) {
+   if (has_prefix(refname, refs/replace/)) {
unsigned char original_sha1[20];
if (!read_replace_refs)
return 0;
@@ -116,11 +116,11 @@ static int add_ref_decoration(const char *refname, const 
unsigned char *sha1, in
if (!obj)
return 0;
 
-   if (!prefixcmp(refname, refs/heads/))
+   if (has_prefix(refname, refs/heads/))
type = DECORATION_REF_LOCAL;
-   else if (!prefixcmp(refname, refs/remotes/))
+   else if (has_prefix(refname, refs/remotes/))
type = DECORATION_REF_REMOTE;
-   else if (!prefixcmp(refname, refs/tags/))
+   else if (has_prefix(refname, refs/tags/))
type = DECORATION_REF_TAG;
else if (!strcmp(refname, refs/stash))
type = DECORATION_REF_STASH;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 24/86] merge-recursive: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 merge-recursive.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index dbb7104..9043362 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -2063,13 +2063,13 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o-recursive_variant = MERGE_RECURSIVE_THEIRS;
else if (!strcmp(s, subtree))
o-subtree_shift = ;
-   else if (!prefixcmp(s, subtree=))
+   else if (has_prefix(s, subtree=))
o-subtree_shift = s + strlen(subtree=);
else if (!strcmp(s, patience))
o-xdl_opts = DIFF_WITH_ALG(o, PATIENCE_DIFF);
else if (!strcmp(s, histogram))
o-xdl_opts = DIFF_WITH_ALG(o, HISTOGRAM_DIFF);
-   else if (!prefixcmp(s, diff-algorithm=)) {
+   else if (has_prefix(s, diff-algorithm=)) {
long value = parse_algorithm_value(s + 
strlen(diff-algorithm=));
if (value  0)
return -1;
@@ -2088,7 +2088,7 @@ int parse_merge_opt(struct merge_options *o, const char 
*s)
o-renormalize = 1;
else if (!strcmp(s, no-renormalize))
o-renormalize = 0;
-   else if (!prefixcmp(s, rename-threshold=)) {
+   else if (has_prefix(s, rename-threshold=)) {
const char *score = s + strlen(rename-threshold=);
if ((o-rename_score = parse_rename_score(score)) == -1 || 
*score != 0)
return -1;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 17/86] tag: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 tag.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tag.c b/tag.c
index 78d272b..0b00c76 100644
--- a/tag.c
+++ b/tag.c
@@ -86,7 +86,7 @@ int parse_tag_buffer(struct tag *item, const void *data, 
unsigned long size)
return -1;
bufptr += 48; /* object  + sha1 + \n */
 
-   if (prefixcmp(bufptr, type ))
+   if (!has_prefix(bufptr, type ))
return -1;
bufptr += 5;
nl = memchr(bufptr, '\n', tail - bufptr);
@@ -109,7 +109,7 @@ int parse_tag_buffer(struct tag *item, const void *data, 
unsigned long size)
item-tagged = NULL;
}
 
-   if (bufptr + 4  tail  !prefixcmp(bufptr, tag ))
+   if (bufptr + 4  tail  has_prefix(bufptr, tag ))
;   /* good */
else
return -1;
@@ -120,7 +120,7 @@ int parse_tag_buffer(struct tag *item, const void *data, 
unsigned long size)
item-tag = xmemdupz(bufptr, nl - bufptr);
bufptr = nl + 1;
 
-   if (bufptr + 7  tail  !prefixcmp(bufptr, tagger ))
+   if (bufptr + 7  tail  has_prefix(bufptr, tagger ))
item-date = parse_tag_date(bufptr, tail);
else
item-date = 0;
@@ -160,8 +160,8 @@ size_t parse_signature(const char *buf, unsigned long size)
 {
char *eol;
size_t len = 0;
-   while (len  size  prefixcmp(buf + len, PGP_SIGNATURE) 
-   prefixcmp(buf + len, PGP_MESSAGE)) {
+   while (len  size  !has_prefix(buf + len, PGP_SIGNATURE) 
+   !has_prefix(buf + len, PGP_MESSAGE)) {
eol = memchr(buf + len, '\n', size - len);
len += eol ? eol - (buf + len) + 1 : size - len;
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/86] strbuf: add has_prefix() to be used instead of prefixcmp()

2013-11-08 Thread Christian Couder
prefixcmp() cannot be really used as a comparison function as
it is not antisymmetric:

prefixcmp(foo, foobar)  0
prefixcmp(foobar, foo) == 0

So it is not suitable as a function for passing to qsort.
And in fact it is used nowhere as a comparison function.

So we should replace it with a function that just checks for
equality.

As a first step toward this goal, this patch introduces
has_prefix().

Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 git-compat-util.h | 1 +
 strbuf.c  | 9 +
 2 files changed, 10 insertions(+)

diff --git a/git-compat-util.h b/git-compat-util.h
index 0f6a31e..7930f49 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -351,6 +351,7 @@ extern void set_error_routine(void (*routine)(const char 
*err, va_list params));
 extern void set_die_is_recursing_routine(int (*routine)(void));
 
 extern int prefixcmp(const char *str, const char *prefix);
+extern int has_prefix(const char *str, const char *prefix);
 extern int has_suffix(const char *str, const char *suffix);
 
 static inline const char *skip_prefix(const char *str, const char *prefix)
diff --git a/strbuf.c b/strbuf.c
index 0d784b5..748be6d 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -10,6 +10,15 @@ int prefixcmp(const char *str, const char *prefix)
return (unsigned char)*prefix - (unsigned char)*str;
 }
 
+int has_prefix(const char *str, const char *prefix)
+{
+   for (; ; str++, prefix++)
+   if (!*prefix)
+   return 1;
+   else if (*str != *prefix)
+   return 0;
+}
+
 int has_suffix(const char *str, const char *suffix)
 {
int len = strlen(str), suflen = strlen(suffix);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 18/86] sequencer: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 sequencer.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 06e52b4..64cc6f0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -41,7 +41,7 @@ static int is_cherry_picked_from_line(const char *buf, int 
len)
 * We only care that it looks roughly like (cherry picked from ...)
 */
return len  strlen(cherry_picked_prefix) + 1 
-   !prefixcmp(buf, cherry_picked_prefix)  buf[len - 1] == ')';
+   has_prefix(buf, cherry_picked_prefix)  buf[len - 1] == ')';
 }
 
 /*
@@ -180,7 +180,7 @@ static char *get_encoding(const char *message)
while (*p  *p != '\n') {
for (eol = p + 1; *eol  *eol != '\n'; eol++)
; /* do nothing */
-   if (!prefixcmp(p, encoding )) {
+   if (has_prefix(p, encoding )) {
char *result = xmalloc(eol - 8 - p);
strlcpy(result, p + 9, eol - 8 - p);
return result;
@@ -705,10 +705,10 @@ static struct commit *parse_insn_line(char *bol, char 
*eol, struct replay_opts *
char *end_of_object_name;
int saved, status, padding;
 
-   if (!prefixcmp(bol, pick)) {
+   if (has_prefix(bol, pick)) {
action = REPLAY_PICK;
bol += strlen(pick);
-   } else if (!prefixcmp(bol, revert)) {
+   } else if (has_prefix(bol, revert)) {
action = REPLAY_REVERT;
bol += strlen(revert);
} else
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 14/86] parse-options: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 parse-options.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/parse-options.c b/parse-options.c
index 62e9b1c..4f7fddc 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -273,13 +273,13 @@ is_abbreviated:
if (options-flags  PARSE_OPT_NONEG)
continue;
/* negated and abbreviated very much? */
-   if (!prefixcmp(no-, arg)) {
+   if (has_prefix(no-, arg)) {
flags |= OPT_UNSET;
goto is_abbreviated;
}
/* negated? */
-   if (prefixcmp(arg, no-)) {
-   if (!prefixcmp(long_name, no-)) {
+   if (!has_prefix(arg, no-)) {
+   if (has_prefix(long_name, no-)) {
long_name += 3;
opt_flags |= OPT_UNSET;
goto again;
@@ -289,7 +289,7 @@ is_abbreviated:
flags |= OPT_UNSET;
rest = skip_prefix(arg + 3, long_name);
/* abbreviated and negated? */
-   if (!rest  !prefixcmp(long_name, arg + 3))
+   if (!rest  has_prefix(long_name, arg + 3))
goto is_abbreviated;
if (!rest)
continue;
@@ -334,7 +334,7 @@ static void check_typos(const char *arg, const struct 
option *options)
if (strlen(arg)  3)
return;
 
-   if (!prefixcmp(arg, no-)) {
+   if (has_prefix(arg, no-)) {
error (did you mean `--%s` (with two dashes ?), arg);
exit(129);
}
@@ -342,7 +342,7 @@ static void check_typos(const char *arg, const struct 
option *options)
for (; options-type != OPTION_END; options++) {
if (!options-long_name)
continue;
-   if (!prefixcmp(options-long_name, arg)) {
+   if (has_prefix(options-long_name, arg)) {
error (did you mean `--%s` (with two dashes ?), arg);
exit(129);
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 27/86] setup: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.c b/setup.c
index f08dd64..6ed292a 100644
--- a/setup.c
+++ b/setup.c
@@ -82,7 +82,7 @@ int check_filename(const char *prefix, const char *arg)
const char *name;
struct stat st;
 
-   if (!prefixcmp(arg, :/)) {
+   if (has_prefix(arg, :/)) {
if (arg[2] == '\0') /* :/ is root dir, always exists */
return 1;
name = arg + 2;
@@ -307,7 +307,7 @@ const char *read_gitfile(const char *path)
if (len != st.st_size)
die(Error reading %s, path);
buf[len] = '\0';
-   if (prefixcmp(buf, gitdir: ))
+   if (!has_prefix(buf, gitdir: ))
die(Invalid gitfile format: %s, path);
while (buf[len - 1] == '\n' || buf[len - 1] == '\r')
len--;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 31/86] send-pack: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 send-pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/send-pack.c b/send-pack.c
index b228d65..c90049a 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -109,7 +109,7 @@ static int receive_status(int in, struct ref *refs)
struct ref *hint;
int ret = 0;
char *line = packet_read_line(in, NULL);
-   if (prefixcmp(line, unpack ))
+   if (!has_prefix(line, unpack ))
return error(did not receive remote status);
if (strcmp(line, unpack ok)) {
error(unpack failed: %s, line + 7);
@@ -122,7 +122,7 @@ static int receive_status(int in, struct ref *refs)
line = packet_read_line(in, NULL);
if (!line)
break;
-   if (prefixcmp(line, ok )  prefixcmp(line, ng )) {
+   if (!has_prefix(line, ok )  !has_prefix(line, ng )) {
error(invalid ref status from remote: %s, line);
ret = -1;
break;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 00/86] replace prefixcmp() with has_prefix()

2013-11-08 Thread Christian Couder
Here is a big patch series to replace prefixcmp() with a new
has_prefix() function.

So the first patch of this series introduces has_prefix()
and the last patch removes prefixcmp().

Except in a few cases, I used a script that does basically
the following to generate the commits in between:

===
#!/bin/bash

perl -pi -e 's/!prefixcmp\(/has_prefix\(/g' $1
perl -pi -e 's/prefixcmp\(/!has_prefix\(/g' $1

git commit -m $1: replace prefixcmd() with has_prefix() $1
===

The few special cases are the following ones:

- remote*: replace prefixcmd() with has_prefix()
- transport*: replace prefixcmd() with has_prefix()
- environment: replace prefixcmd() with has_prefix()

In first 2 cases above, I processed a few files at the same
time instead of just one.

In the case of environment, I removed  != 0 after
!has_prefix(...) as it is not necessary and makes it
more difficult to understand the logic.

Of course it's possible to squash many of the commits
together if it is prefered.

Christian Couder (86):
  strbuf: add has_prefix() to be used instead of prefixcmp()
  diff: replace prefixcmd() with has_prefix()
  fast-import: replace prefixcmd() with has_prefix()
  remote*: replace prefixcmd() with has_prefix()
  daemon: replace prefixcmd() with has_prefix()
  pretty: replace prefixcmd() with has_prefix()
  revision: replace prefixcmd() with has_prefix()
  transport*: replace prefixcmd() with has_prefix()
  config: replace prefixcmd() with has_prefix()
  sha1_name: replace prefixcmd() with has_prefix()
  wt-status: replace prefixcmd() with has_prefix()
  upload-pack: replace prefixcmd() with has_prefix()
  test-line-buffer: replace prefixcmd() with has_prefix()
  parse-options: replace prefixcmd() with has_prefix()
  fetch-pack: replace prefixcmd() with has_prefix()
  git: replace prefixcmd() with has_prefix()
  tag: replace prefixcmd() with has_prefix()
  sequencer: replace prefixcmd() with has_prefix()
  commit: replace prefixcmd() with has_prefix()
  http: replace prefixcmd() with has_prefix()
  imap-send: replace prefixcmd() with has_prefix()
  help: replace prefixcmd() with has_prefix()
  log-tree: replace prefixcmd() with has_prefix()
  merge-recursive: replace prefixcmd() with has_prefix()
  notes: replace prefixcmd() with has_prefix()
  refs: replace prefixcmd() with has_prefix()
  setup: replace prefixcmd() with has_prefix()
  bisect: replace prefixcmd() with has_prefix()
  branch: replace prefixcmd() with has_prefix()
  http-push: replace prefixcmd() with has_prefix()
  send-pack: replace prefixcmd() with has_prefix()
  http-backend: replace prefixcmd() with has_prefix()
  notes-utils: replace prefixcmd() with has_prefix()
  pkt-line: replace prefixcmd() with has_prefix()
  alias: replace prefixcmd() with has_prefix()
  attr: replace prefixcmd() with has_prefix()
  connect: replace prefixcmd() with has_prefix()
  pager: replace prefixcmd() with has_prefix()
  convert: replace prefixcmd() with has_prefix()
  environment: replace prefixcmd() with has_prefix()
  shell: replace prefixcmd() with has_prefix()
  pathspec: replace prefixcmd() with has_prefix()
  submodule: replace prefixcmd() with has_prefix()
  test-string-list: replace prefixcmd() with has_prefix()
  builtin/apply: replace prefixcmd() with has_prefix()
  builtin/archive: replace prefixcmd() with has_prefix()
  builtin/branch: replace prefixcmd() with has_prefix()
  builtin/checkout: replace prefixcmd() with has_prefix()
  builtin/clean: replace prefixcmd() with has_prefix()
  builtin/clone: replace prefixcmd() with has_prefix()
  builtin/column: replace prefixcmd() with has_prefix()
  builtin/commit: replace prefixcmd() with has_prefix()
  builtin/describe: replace prefixcmd() with has_prefix()
  builtin/fast-export: replace prefixcmd() with has_prefix()
  builtin/fetch-pack: replace prefixcmd() with has_prefix()
  builtin/fetch: replace prefixcmd() with has_prefix()
  builtin/fmt-merge-msg: replace prefixcmd() with has_prefix()
  builtin/for-each-ref: replace prefixcmd() with has_prefix()
  builtin/fsck: replace prefixcmd() with has_prefix()
  builtin/help: replace prefixcmd() with has_prefix()
  builtin/index-pack: replace prefixcmd() with has_prefix()
  builtin/init-db: replace prefixcmd() with has_prefix()
  builtin/log: replace prefixcmd() with has_prefix()
  builtin/ls-remote: replace prefixcmd() with has_prefix()
  builtin/mailinfo: replace prefixcmd() with has_prefix()
  builtin/merge-recursive: replace prefixcmd() with has_prefix()
  builtin/merge: replace prefixcmd() with has_prefix()
  builtin/name-rev: replace prefixcmd() with has_prefix()
  builtin/notes: replace prefixcmd() with has_prefix()
  builtin/pack-objects: replace prefixcmd() with has_prefix()
  builtin/prune: replace prefixcmd() with has_prefix()
  builtin/receive-pack: replace prefixcmd() with has_prefix()
  builtin/reflog: replace prefixcmd() with has_prefix()
  builtin/remote: replace prefixcmd() with has_prefix()
  builtin/rev-parse: replace

[PATCH 34/86] pkt-line: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 pkt-line.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pkt-line.c b/pkt-line.c
index 70f1950..d967727 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -24,8 +24,8 @@ static void packet_trace(const char *buf, unsigned int len, 
int write)
strbuf_addf(out, packet: %12s%c ,
packet_trace_prefix, write ? '' : '');
 
-   if ((len = 4  !prefixcmp(buf, PACK)) ||
-   (len = 5  !prefixcmp(buf+1, PACK))) {
+   if ((len = 4  has_prefix(buf, PACK)) ||
+   (len = 5  has_prefix(buf+1, PACK))) {
strbuf_addstr(out, PACK ...);
unsetenv(trace_key);
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 26/86] refs: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 refs.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/refs.c b/refs.c
index 3710748..3dc38df 100644
--- a/refs.c
+++ b/refs.c
@@ -637,7 +637,7 @@ static int do_one_ref(struct ref_entry *entry, void 
*cb_data)
struct ref_entry *old_current_ref;
int retval;
 
-   if (prefixcmp(entry-name, data-base))
+   if (!has_prefix(entry-name, data-base))
return 0;
 
if (!(data-flags  DO_FOR_EACH_INCLUDE_BROKEN) 
@@ -1049,7 +1049,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir)
if (refname) {
last = create_ref_entry(refname, sha1, REF_ISPACKED, 1);
if (peeled == PEELED_FULLY ||
-   (peeled == PEELED_TAGS  !prefixcmp(refname, 
refs/tags/)))
+   (peeled == PEELED_TAGS  has_prefix(refname, 
refs/tags/)))
last-flag |= REF_KNOWS_PEELED;
add_ref(dir, last);
continue;
@@ -1383,7 +1383,7 @@ const char *resolve_ref_unsafe(const char *refname, 
unsigned char *sha1, int rea
return NULL;
}
buffer[len] = 0;
-   if (!prefixcmp(buffer, refs/) 
+   if (has_prefix(buffer, refs/) 
!check_refname_format(buffer, 0)) {
strcpy(refname_buffer, buffer);
refname = refname_buffer;
@@ -1422,7 +1422,7 @@ const char *resolve_ref_unsafe(const char *refname, 
unsigned char *sha1, int rea
/*
 * Is it a symbolic ref?
 */
-   if (prefixcmp(buffer, ref:)) {
+   if (!has_prefix(buffer, ref:)) {
/*
 * Please note that FETCH_HEAD has a second
 * line containing other data.
@@ -1844,7 +1844,7 @@ int for_each_glob_ref_in(each_ref_fn fn, const char 
*pattern,
struct ref_filter filter;
int ret;
 
-   if (!prefix  prefixcmp(pattern, refs/))
+   if (!prefix  !has_prefix(pattern, refs/))
strbuf_addstr(real_pattern, refs/);
else if (prefix)
strbuf_addstr(real_pattern, prefix);
@@ -1881,9 +1881,9 @@ int for_each_rawref(each_ref_fn fn, void *cb_data)
 const char *prettify_refname(const char *name)
 {
return name + (
-   !prefixcmp(name, refs/heads/) ? 11 :
-   !prefixcmp(name, refs/tags/) ? 10 :
-   !prefixcmp(name, refs/remotes/) ? 13 :
+   has_prefix(name, refs/heads/) ? 11 :
+   has_prefix(name, refs/tags/) ? 10 :
+   has_prefix(name, refs/remotes/) ? 13 :
0);
 }
 
@@ -2251,7 +2251,7 @@ static int pack_if_possible_fn(struct ref_entry *entry, 
void *cb_data)
struct pack_refs_cb_data *cb = cb_data;
enum peel_status peel_status;
struct ref_entry *packed_entry;
-   int is_tag_ref = !prefixcmp(entry-name, refs/tags/);
+   int is_tag_ref = has_prefix(entry-name, refs/tags/);
 
/* ALWAYS pack tags */
if (!(cb-flags  PACK_REFS_ALL)  !is_tag_ref)
@@ -2686,9 +2686,9 @@ int log_ref_setup(const char *refname, char *logfile, int 
bufsize)
 
git_snpath(logfile, bufsize, logs/%s, refname);
if (log_all_ref_updates 
-   (!prefixcmp(refname, refs/heads/) ||
-!prefixcmp(refname, refs/remotes/) ||
-!prefixcmp(refname, refs/notes/) ||
+   (has_prefix(refname, refs/heads/) ||
+has_prefix(refname, refs/remotes/) ||
+has_prefix(refname, refs/notes/) ||
 !strcmp(refname, HEAD))) {
if (safe_create_leading_directories(logfile)  0)
return error(unable to create directory for %s,
@@ -2758,7 +2758,7 @@ static int log_ref_write(const char *refname, const 
unsigned char *old_sha1,
 
 static int is_branch(const char *refname)
 {
-   return !strcmp(refname, HEAD) || !prefixcmp(refname, refs/heads/);
+   return !strcmp(refname, HEAD) || has_prefix(refname, refs/heads/);
 }
 
 int write_ref_sha1(struct ref_lock *lock,
@@ -3457,7 +3457,7 @@ int parse_hide_refs_config(const char *var, const char 
*value, const char *secti
 {
if (!strcmp(transfer.hiderefs, var) ||
/* NEEDSWORK: use parse_config_key() once both are merged */
-   (!prefixcmp(var, section)  var[strlen(section)] == '.' 
+   (has_prefix(var, section)  var[strlen(section)] == '.' 
 !strcmp(var + strlen(section), .hiderefs))) {
char *ref;
int len;
@@ -3485,7 +3485,7 @@ int ref_is_hidden(const char *refname)
return 0;
for_each_string_list_item(item, hide_refs

[PATCH 49/86] builtin/clean: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/clean.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/clean.c b/builtin/clean.c
index 615cd57..98887cd 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -100,7 +100,7 @@ static int parse_clean_color_slot(const char *var)
 
 static int git_clean_config(const char *var, const char *value, void *cb)
 {
-   if (!prefixcmp(var, column.))
+   if (has_prefix(var, column.))
return git_column_config(var, value, clean, colopts);
 
/* honors the color.interactive* config variables which also
@@ -109,7 +109,7 @@ static int git_clean_config(const char *var, const char 
*value, void *cb)
clean_use_color = git_config_colorbool(var, value);
return 0;
}
-   if (!prefixcmp(var, color.interactive.)) {
+   if (has_prefix(var, color.interactive.)) {
int slot = parse_clean_color_slot(var +
  strlen(color.interactive.));
if (slot  0)
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 25/86] notes: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 notes.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/notes.c b/notes.c
index b69c0b8..e23d38a 100644
--- a/notes.c
+++ b/notes.c
@@ -1243,9 +1243,9 @@ static void format_note(struct notes_tree *t, const 
unsigned char *object_sha1,
if (!ref || !strcmp(ref, GIT_NOTES_DEFAULT_REF)) {
strbuf_addstr(sb, \nNotes:\n);
} else {
-   if (!prefixcmp(ref, refs/))
+   if (has_prefix(ref, refs/))
ref += 5;
-   if (!prefixcmp(ref, notes/))
+   if (has_prefix(ref, notes/))
ref += 6;
strbuf_addf(sb, \nNotes (%s):\n, ref);
}
@@ -1293,9 +1293,9 @@ int copy_note(struct notes_tree *t,
 
 void expand_notes_ref(struct strbuf *sb)
 {
-   if (!prefixcmp(sb-buf, refs/notes/))
+   if (has_prefix(sb-buf, refs/notes/))
return; /* we're happy */
-   else if (!prefixcmp(sb-buf, notes/))
+   else if (has_prefix(sb-buf, notes/))
strbuf_insert(sb, 0, refs/, 5);
else
strbuf_insert(sb, 0, refs/notes/, 11);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/86] remote*: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 remote-curl.c| 14 +++---
 remote-testsvn.c | 10 +-
 remote.c | 46 +++---
 3 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/remote-curl.c b/remote-curl.c
index b5ebe01..437b863 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -212,7 +212,7 @@ static struct discovery* discover_refs(const char *service, 
int for_push)
free_discovery(last);
 
strbuf_addf(buffer, %sinfo/refs, url);
-   if ((!prefixcmp(url, http://;) || !prefixcmp(url, https://;)) 
+   if ((has_prefix(url, http://;) || has_prefix(url, https://;)) 
 git_env_bool(GIT_SMART_HTTP, 1)) {
maybe_smart = 1;
if (!strchr(url, '?'))
@@ -740,7 +740,7 @@ static void parse_fetch(struct strbuf *buf)
int alloc_heads = 0, nr_heads = 0;
 
do {
-   if (!prefixcmp(buf-buf, fetch )) {
+   if (has_prefix(buf-buf, fetch )) {
char *p = buf-buf + strlen(fetch );
char *name;
struct ref *ref;
@@ -863,7 +863,7 @@ static void parse_push(struct strbuf *buf)
int alloc_spec = 0, nr_spec = 0, i, ret;
 
do {
-   if (!prefixcmp(buf-buf, push )) {
+   if (has_prefix(buf-buf, push )) {
ALLOC_GROW(specs, nr_spec + 1, alloc_spec);
specs[nr_spec++] = xstrdup(buf-buf + 5);
}
@@ -928,19 +928,19 @@ int main(int argc, const char **argv)
}
if (buf.len == 0)
break;
-   if (!prefixcmp(buf.buf, fetch )) {
+   if (has_prefix(buf.buf, fetch )) {
if (nongit)
die(Fetch attempted without a local repo);
parse_fetch(buf);
 
-   } else if (!strcmp(buf.buf, list) || !prefixcmp(buf.buf, 
list )) {
+   } else if (!strcmp(buf.buf, list) || has_prefix(buf.buf, 
list )) {
int for_push = !!strstr(buf.buf + 4, for-push);
output_refs(get_refs(for_push));
 
-   } else if (!prefixcmp(buf.buf, push )) {
+   } else if (has_prefix(buf.buf, push )) {
parse_push(buf);
 
-   } else if (!prefixcmp(buf.buf, option )) {
+   } else if (has_prefix(buf.buf, option )) {
char *name = buf.buf + strlen(option );
char *value = strchr(name, ' ');
int result;
diff --git a/remote-testsvn.c b/remote-testsvn.c
index d7cd5d2..7a5d4c8 100644
--- a/remote-testsvn.c
+++ b/remote-testsvn.c
@@ -82,7 +82,7 @@ static int parse_rev_note(const char *msg, struct rev_note 
*res)
len = end ? end - msg : strlen(msg);
 
key = Revision-number: ;
-   if (!prefixcmp(msg, key)) {
+   if (has_prefix(msg, key)) {
long i;
char *end;
value = msg + strlen(key);
@@ -154,7 +154,7 @@ static void check_or_regenerate_marks(int latestrev)
} else {
strbuf_addf(sb, :%d , latestrev);
while (strbuf_getline(line, marksfile, '\n') != EOF) {
-   if (!prefixcmp(line.buf, sb.buf)) {
+   if (has_prefix(line.buf, sb.buf)) {
found++;
break;
}
@@ -264,7 +264,7 @@ static int do_command(struct strbuf *line)
return 1;   /* end of command stream, quit */
}
if (batch_cmd) {
-   if (prefixcmp(batch_cmd-name, line-buf))
+   if (!has_prefix(batch_cmd-name, line-buf))
die(Active %s batch interrupted by %s, 
batch_cmd-name, line-buf);
/* buffer batch lines */
string_list_append(batchlines, line-buf);
@@ -272,7 +272,7 @@ static int do_command(struct strbuf *line)
}
 
for (p = input_command_list; p-name; p++) {
-   if (!prefixcmp(line-buf, p-name)  (strlen(p-name) == 
line-len ||
+   if (has_prefix(line-buf, p-name)  (strlen(p-name) == 
line-len ||
line-buf[strlen(p-name)] == ' ')) {
if (p-batchable) {
batch_cmd = p;
@@ -304,7 +304,7 @@ int main(int argc, char **argv)
remote = remote_get(argv[1]);
url_in = (argc == 3) ? argv[2] : remote-url[0];
 
-   if (!prefixcmp(url_in, file://)) {
+   if (has_prefix(url_in, file://)) {
dump_from_file = 1;
url = url_decode(url_in + sizeof(file://)-1);
} else {
diff --git a/remote.c b/remote.c
index e9fedfa..84c0d9f 100644
--- a/remote.c
+++ b/remote.c
@@ -76,7 +76,7

[PATCH 35/86] alias: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 alias.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/alias.c b/alias.c
index eb9f08b..0933c87 100644
--- a/alias.c
+++ b/alias.c
@@ -5,7 +5,7 @@ static char *alias_val;
 
 static int alias_lookup_cb(const char *k, const char *v, void *cb)
 {
-   if (!prefixcmp(k, alias.)  !strcmp(k+6, alias_key)) {
+   if (has_prefix(k, alias.)  !strcmp(k+6, alias_key)) {
if (!v)
return config_error_nonbool(k);
alias_val = xstrdup(v);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 12/86] upload-pack: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 upload-pack.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/upload-pack.c b/upload-pack.c
index a6c54e0..ce4ae75 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -394,7 +394,7 @@ static int get_common_commits(void)
got_other = 0;
continue;
}
-   if (!prefixcmp(line, have )) {
+   if (has_prefix(line, have )) {
switch (got_sha1(line+5, sha1)) {
case -1: /* they have what we do not */
got_other = 1;
@@ -540,7 +540,7 @@ static void receive_needs(void)
if (!line)
break;
 
-   if (!prefixcmp(line, shallow )) {
+   if (has_prefix(line, shallow )) {
unsigned char sha1[20];
struct object *object;
if (get_sha1_hex(line + 8, sha1))
@@ -556,14 +556,14 @@ static void receive_needs(void)
}
continue;
}
-   if (!prefixcmp(line, deepen )) {
+   if (has_prefix(line, deepen )) {
char *end;
depth = strtol(line + 7, end, 0);
if (end == line + 7 || depth = 0)
die(Invalid deepen: %s, line);
continue;
}
-   if (prefixcmp(line, want ) ||
+   if (!has_prefix(line, want ) ||
get_sha1_hex(line+5, sha1_buf))
die(git upload-pack: protocol error, 
expected to get sha, not '%s', line);
@@ -777,7 +777,7 @@ int main(int argc, char **argv)
strict = 1;
continue;
}
-   if (!prefixcmp(arg, --timeout=)) {
+   if (has_prefix(arg, --timeout=)) {
timeout = atoi(arg+10);
daemon_mode = 1;
continue;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/86] revision: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 revision.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/revision.c b/revision.c
index 0173e01..968320a 100644
--- a/revision.c
+++ b/revision.c
@@ -1576,9 +1576,9 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
!strcmp(arg, --tags) || !strcmp(arg, --remotes) ||
!strcmp(arg, --reflog) || !strcmp(arg, --not) ||
!strcmp(arg, --no-walk) || !strcmp(arg, --do-walk) ||
-   !strcmp(arg, --bisect) || !prefixcmp(arg, --glob=) ||
-   !prefixcmp(arg, --branches=) || !prefixcmp(arg, --tags=) ||
-   !prefixcmp(arg, --remotes=) || !prefixcmp(arg, --no-walk=))
+   !strcmp(arg, --bisect) || has_prefix(arg, --glob=) ||
+   has_prefix(arg, --branches=) || has_prefix(arg, --tags=) ||
+   has_prefix(arg, --remotes=) || has_prefix(arg, --no-walk=))
{
unkv[(*unkc)++] = arg;
return 1;
@@ -1601,7 +1601,7 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
revs-max_count = atoi(argv[1]);
revs-no_walk = 0;
return 2;
-   } else if (!prefixcmp(arg, -n)) {
+   } else if (has_prefix(arg, -n)) {
revs-max_count = atoi(arg + 2);
revs-no_walk = 0;
} else if ((argcount = parse_long_opt(max-age, argv, optarg))) {
@@ -1661,7 +1661,7 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
} else if (!strcmp(arg, --author-date-order)) {
revs-sort_order = REV_SORT_BY_AUTHOR_DATE;
revs-topo_order = 1;
-   } else if (!prefixcmp(arg, --early-output)) {
+   } else if (has_prefix(arg, --early-output)) {
int count = 100;
switch (arg[14]) {
case '=':
@@ -1686,13 +1686,13 @@ static int handle_revision_opt(struct rev_info *revs, 
int argc, const char **arg
revs-min_parents = 2;
} else if (!strcmp(arg, --no-merges)) {
revs-max_parents = 1;
-   } else if (!prefixcmp(arg, --min-parents=)) {
+   } else if (has_prefix(arg, --min-parents=)) {
revs-min_parents = atoi(arg+14);
-   } else if (!prefixcmp(arg, --no-min-parents)) {
+   } else if (has_prefix(arg, --no-min-parents)) {
revs-min_parents = 0;
-   } else if (!prefixcmp(arg, --max-parents=)) {
+   } else if (has_prefix(arg, --max-parents=)) {
revs-max_parents = atoi(arg+14);
-   } else if (!prefixcmp(arg, --no-max-parents)) {
+   } else if (has_prefix(arg, --no-max-parents)) {
revs-max_parents = -1;
} else if (!strcmp(arg, --boundary)) {
revs-boundary = 1;
@@ -1742,7 +1742,7 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
revs-verify_objects = 1;
} else if (!strcmp(arg, --unpacked)) {
revs-unpacked = 1;
-   } else if (!prefixcmp(arg, --unpacked=)) {
+   } else if (has_prefix(arg, --unpacked=)) {
die(--unpacked=packfile no longer supported.);
} else if (!strcmp(arg, -r)) {
revs-diff = 1;
@@ -1767,7 +1767,7 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
revs-verbose_header = 1;
revs-pretty_given = 1;
get_commit_format(arg+8, revs);
-   } else if (!prefixcmp(arg, --pretty=) || !prefixcmp(arg, 
--format=)) {
+   } else if (has_prefix(arg, --pretty=) || has_prefix(arg, 
--format=)) {
/*
 * Detached form (--pretty X as opposed to --pretty=X)
 * not allowed, since the argument is optional.
@@ -1781,12 +1781,12 @@ static int handle_revision_opt(struct rev_info *revs, 
int argc, const char **arg
revs-notes_opt.use_default_notes = 1;
} else if (!strcmp(arg, --show-signature)) {
revs-show_signature = 1;
-   } else if (!prefixcmp(arg, --show-notes=) ||
-  !prefixcmp(arg, --notes=)) {
+   } else if (has_prefix(arg, --show-notes=) ||
+  has_prefix(arg, --notes=)) {
struct strbuf buf = STRBUF_INIT;
revs-show_notes = 1;
revs-show_notes_given = 1;
-   if (!prefixcmp(arg, --show-notes)) {
+   if (has_prefix(arg, --show-notes)) {
if (revs-notes_opt.use_default_notes  0)
revs-notes_opt.use_default_notes = 1;
strbuf_addstr(buf, arg+13);
@@ -1829,7 +1829,7 @@ static int handle_revision_opt(struct rev_info *revs, int 
argc, const char **arg
revs-abbrev = 0;
} else if (!strcmp(arg, --abbrev)) {
revs-abbrev

[PATCH 43/86] submodule: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 submodule.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/submodule.c b/submodule.c
index 1905d75..21fe14e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -201,7 +201,7 @@ void set_diffopt_flags_from_submodule_config(struct 
diff_options *diffopt,
 
 int submodule_config(const char *var, const char *value, void *cb)
 {
-   if (!prefixcmp(var, submodule.))
+   if (has_prefix(var, submodule.))
return parse_submodule_config_option(var, value);
else if (!strcmp(var, fetch.recursesubmodules)) {
config_fetch_recurse_submodules = 
parse_fetch_recurse_submodules_arg(var, value);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 47/86] builtin/branch: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/branch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/branch.c b/builtin/branch.c
index ad0f86d..c4cb81c 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -81,13 +81,13 @@ static int parse_branch_color_slot(const char *var, int ofs)
 
 static int git_branch_config(const char *var, const char *value, void *cb)
 {
-   if (!prefixcmp(var, column.))
+   if (has_prefix(var, column.))
return git_column_config(var, value, branch, colopts);
if (!strcmp(var, color.branch)) {
branch_use_color = git_config_colorbool(var, value);
return 0;
}
-   if (!prefixcmp(var, color.branch.)) {
+   if (has_prefix(var, color.branch.)) {
int slot = parse_branch_color_slot(var, 13);
if (slot  0)
return 0;
@@ -862,7 +862,7 @@ int cmd_branch(int argc, const char **argv, const char 
*prefix)
if (!strcmp(head, HEAD)) {
detached = 1;
} else {
-   if (prefixcmp(head, refs/heads/))
+   if (!has_prefix(head, refs/heads/))
die(_(HEAD not found below refs/heads!));
head += 11;
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 44/86] test-string-list: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 test-string-list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test-string-list.c b/test-string-list.c
index 00ce6c9..e04a37c 100644
--- a/test-string-list.c
+++ b/test-string-list.c
@@ -38,7 +38,7 @@ static void write_list_compact(const struct string_list *list)
 static int prefix_cb(struct string_list_item *item, void *cb_data)
 {
const char *prefix = (const char *)cb_data;
-   return !prefixcmp(item-string, prefix);
+   return has_prefix(item-string, prefix);
 }
 
 int main(int argc, char **argv)
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 51/86] builtin/column: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/column.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/column.c b/builtin/column.c
index e125a55..3664cc1 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -34,7 +34,7 @@ int cmd_column(int argc, const char **argv, const char 
*prefix)
};
 
/* This one is special and must be the first one */
-   if (argc  1  !prefixcmp(argv[1], --command=)) {
+   if (argc  1  has_prefix(argv[1], --command=)) {
command = argv[1] + 10;
git_config(column_config, (void *)command);
} else
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 50/86] builtin/clone: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/clone.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index 84fb1bd..49b7a08 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -508,7 +508,7 @@ static void write_followtags(const struct ref *refs, const 
char *msg)
 {
const struct ref *ref;
for (ref = refs; ref; ref = ref-next) {
-   if (prefixcmp(ref-name, refs/tags/))
+   if (!has_prefix(ref-name, refs/tags/))
continue;
if (has_suffix(ref-name, ^{}))
continue;
@@ -578,7 +578,7 @@ static void update_remote_refs(const struct ref *refs,
 static void update_head(const struct ref *our, const struct ref *remote,
const char *msg)
 {
-   if (our  !prefixcmp(our-name, refs/heads/)) {
+   if (our  has_prefix(our-name, refs/heads/)) {
/* Local default branch link */
create_symref(HEAD, our-name, NULL);
if (!option_bare) {
@@ -625,7 +625,7 @@ static int checkout(void)
if (advice_detached_head)
detach_advice(sha1_to_hex(sha1));
} else {
-   if (prefixcmp(head, refs/heads/))
+   if (!has_prefix(head, refs/heads/))
die(_(HEAD not found below refs/heads!));
}
free(head);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 33/86] notes-utils: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 notes-utils.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/notes-utils.c b/notes-utils.c
index 9107c37..0a4c3de 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -70,7 +70,7 @@ static combine_notes_fn parse_combine_notes_fn(const char *v)
 static int notes_rewrite_config(const char *k, const char *v, void *cb)
 {
struct notes_rewrite_cfg *c = cb;
-   if (!prefixcmp(k, notes.rewrite.)  !strcmp(k+14, c-cmd)) {
+   if (has_prefix(k, notes.rewrite.)  !strcmp(k+14, c-cmd)) {
c-enabled = git_config_bool(k, v);
return 0;
} else if (!c-mode_from_env  !strcmp(k, notes.rewritemode)) {
@@ -85,7 +85,7 @@ static int notes_rewrite_config(const char *k, const char *v, 
void *cb)
} else if (!c-refs_from_env  !strcmp(k, notes.rewriteref)) {
/* note that a refs/ prefix is implied in the
 * underlying for_each_glob_ref */
-   if (!prefixcmp(v, refs/notes/))
+   if (has_prefix(v, refs/notes/))
string_list_add_refs_by_glob(c-refs, v);
else
warning(_(Refusing to rewrite notes in %s
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 32/86] http-backend: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 http-backend.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/http-backend.c b/http-backend.c
index 8c464bd..d0183b1 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -226,7 +226,7 @@ static int http_config(const char *var, const char *value, 
void *cb)
return 0;
}
 
-   if (!prefixcmp(var, http.)) {
+   if (has_prefix(var, http.)) {
int i;
 
for (i = 0; i  ARRAY_SIZE(rpc_service); i++) {
@@ -247,7 +247,7 @@ static struct rpc_service *select_service(const char *name)
struct rpc_service *svc = NULL;
int i;
 
-   if (prefixcmp(name, git-))
+   if (!has_prefix(name, git-))
forbidden(Unsupported service: '%s', name);
 
for (i = 0; i  ARRAY_SIZE(rpc_service); i++) {
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 55/86] builtin/fetch-pack: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/fetch-pack.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index c8e8582..29a3b33 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -48,11 +48,11 @@ int cmd_fetch_pack(int argc, const char **argv, const char 
*prefix)
for (i = 1; i  argc  *argv[i] == '-'; i++) {
const char *arg = argv[i];
 
-   if (!prefixcmp(arg, --upload-pack=)) {
+   if (has_prefix(arg, --upload-pack=)) {
args.uploadpack = arg + 14;
continue;
}
-   if (!prefixcmp(arg, --exec=)) {
+   if (has_prefix(arg, --exec=)) {
args.uploadpack = arg + 7;
continue;
}
@@ -85,7 +85,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char 
*prefix)
args.verbose = 1;
continue;
}
-   if (!prefixcmp(arg, --depth=)) {
+   if (has_prefix(arg, --depth=)) {
args.depth = strtol(arg + 8, NULL, 0);
continue;
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 19/86] commit: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 commit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/commit.c b/commit.c
index de16a3c..35b276d 100644
--- a/commit.c
+++ b/commit.c
@@ -559,7 +559,7 @@ static void record_author_date(struct author_date_slab 
*author_date,
 buf;
 buf = line_end + 1) {
line_end = strchrnul(buf, '\n');
-   if (prefixcmp(buf, author )) {
+   if (!has_prefix(buf, author )) {
if (!line_end[0] || line_end[1] == '\n')
return; /* end of header */
continue;
@@ -1106,7 +1106,7 @@ int parse_signed_commit(const unsigned char *sha1,
next = next ? next + 1 : tail;
if (in_signature  line[0] == ' ')
sig = line + 1;
-   else if (!prefixcmp(line, gpg_sig_header) 
+   else if (has_prefix(line, gpg_sig_header) 
 line[gpg_sig_header_len] == ' ')
sig = line + gpg_sig_header_len + 1;
if (sig) {
@@ -1186,7 +1186,7 @@ static void parse_gpg_output(struct signature_check *sigc)
for (i = 0; i  ARRAY_SIZE(sigcheck_gpg_status); i++) {
const char *found, *next;
 
-   if (!prefixcmp(buf, sigcheck_gpg_status[i].check + 1)) {
+   if (has_prefix(buf, sigcheck_gpg_status[i].check + 1)) {
/* At the very beginning of the buffer */
found = buf + strlen(sigcheck_gpg_status[i].check + 1);
} else {
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 52/86] builtin/commit: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/commit.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/commit.c b/builtin/commit.c
index 6ab4605..a8c46c6 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -733,7 +733,7 @@ static int prepare_to_commit(const char *index_file, const 
char *prefix,
eol = nl - sb.buf;
else
eol = sb.len;
-   if (!prefixcmp(sb.buf + previous, \nConflicts:\n)) {
+   if (has_prefix(sb.buf + previous, \nConflicts:\n)) {
ignore_footer = sb.len - previous;
break;
}
@@ -904,7 +904,7 @@ static int rest_is_empty(struct strbuf *sb, int start)
eol = sb-len;
 
if (strlen(sign_off_header) = eol - i 
-   !prefixcmp(sb-buf + i, sign_off_header)) {
+   has_prefix(sb-buf + i, sign_off_header)) {
i = eol;
continue;
}
@@ -1183,7 +1183,7 @@ static int git_status_config(const char *k, const char 
*v, void *cb)
 {
struct wt_status *s = cb;
 
-   if (!prefixcmp(k, column.))
+   if (has_prefix(k, column.))
return git_column_config(k, v, status, s-colopts);
if (!strcmp(k, status.submodulesummary)) {
int is_bool;
@@ -1211,7 +1211,7 @@ static int git_status_config(const char *k, const char 
*v, void *cb)
s-display_comment_prefix = git_config_bool(k, v);
return 0;
}
-   if (!prefixcmp(k, status.color.) || !prefixcmp(k, color.status.)) {
+   if (has_prefix(k, status.color.) || has_prefix(k, color.status.)) {
int slot = parse_status_slot(k, 13);
if (slot  0)
return 0;
@@ -1377,7 +1377,7 @@ static void print_summary(const char *prefix, const 
unsigned char *sha1,
 
head = resolve_ref_unsafe(HEAD, junk_sha1, 0, NULL);
printf([%s%s ,
-   !prefixcmp(head, refs/heads/) ?
+   has_prefix(head, refs/heads/) ?
head + 11 :
!strcmp(head, HEAD) ?
_(detached HEAD) :
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/86] diff: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 diff.c | 56 
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/diff.c b/diff.c
index a04a34d..b42523a 100644
--- a/diff.c
+++ b/diff.c
@@ -235,7 +235,7 @@ int git_diff_basic_config(const char *var, const char 
*value, void *cb)
if (userdiff_config(var, value)  0)
return -1;
 
-   if (!prefixcmp(var, diff.color.) || !prefixcmp(var, color.diff.)) {
+   if (has_prefix(var, diff.color.) || has_prefix(var, color.diff.)) {
int slot = parse_diff_color_slot(var, 11);
if (slot  0)
return 0;
@@ -264,7 +264,7 @@ int git_diff_basic_config(const char *var, const char 
*value, void *cb)
return 0;
}
 
-   if (!prefixcmp(var, submodule.))
+   if (has_prefix(var, submodule.))
return parse_submodule_config_option(var, value);
 
return git_default_config(var, value, cb);
@@ -1215,7 +1215,7 @@ static void fn_out_consume(void *priv, char *line, 
unsigned long len)
diff_words_append(line, len,
  ecbdata-diff_words-plus);
return;
-   } else if (!prefixcmp(line, \\ )) {
+   } else if (has_prefix(line, \\ )) {
/*
 * Eat the no newline at eof marker as if we
 * saw a + or - line with nothing on it,
@@ -2387,9 +2387,9 @@ static void builtin_diff(const char *name_a,
xdiff_set_find_func(xecfg, pe-pattern, pe-cflags);
if (!diffopts)
;
-   else if (!prefixcmp(diffopts, --unified=))
+   else if (has_prefix(diffopts, --unified=))
xecfg.ctxlen = strtoul(diffopts + 10, NULL, 10);
-   else if (!prefixcmp(diffopts, -u))
+   else if (has_prefix(diffopts, -u))
xecfg.ctxlen = strtoul(diffopts + 2, NULL, 10);
if (o-word_diff)
init_diff_words_data(ecbdata, o, one, two);
@@ -3388,7 +3388,7 @@ int parse_long_opt(const char *opt, const char **argv,
if (arg[0] != '-' || arg[1] != '-')
return 0;
arg += strlen(--);
-   if (prefixcmp(arg, opt))
+   if (!has_prefix(arg, opt))
return 0;
arg += strlen(opt);
if (*arg == '=') { /* sticked form: --option=value */
@@ -3419,7 +3419,7 @@ static int stat_opt(struct diff_options *options, const 
char **av)
 
switch (*arg) {
case '-':
-   if (!prefixcmp(arg, -width)) {
+   if (has_prefix(arg, -width)) {
arg += strlen(-width);
if (*arg == '=')
width = strtoul(arg + 1, end, 10);
@@ -3429,7 +3429,7 @@ static int stat_opt(struct diff_options *options, const 
char **av)
width = strtoul(av[1], end, 10);
argcount = 2;
}
-   } else if (!prefixcmp(arg, -name-width)) {
+   } else if (has_prefix(arg, -name-width)) {
arg += strlen(-name-width);
if (*arg == '=')
name_width = strtoul(arg + 1, end, 10);
@@ -3439,7 +3439,7 @@ static int stat_opt(struct diff_options *options, const 
char **av)
name_width = strtoul(av[1], end, 10);
argcount = 2;
}
-   } else if (!prefixcmp(arg, -graph-width)) {
+   } else if (has_prefix(arg, -graph-width)) {
arg += strlen(-graph-width);
if (*arg == '=')
graph_width = strtoul(arg + 1, end, 10);
@@ -3449,7 +3449,7 @@ static int stat_opt(struct diff_options *options, const 
char **av)
graph_width = strtoul(av[1], end, 10);
argcount = 2;
}
-   } else if (!prefixcmp(arg, -count)) {
+   } else if (has_prefix(arg, -count)) {
arg += strlen(-count);
if (*arg == '=')
count = strtoul(arg + 1, end, 10);
@@ -3611,15 +3611,15 @@ int diff_opt_parse(struct diff_options *options, const 
char **av, int ac)
options-output_format |= DIFF_FORMAT_SHORTSTAT;
else if (!strcmp(arg, -X) || !strcmp(arg, --dirstat))
return parse_dirstat_opt(options, );
-   else if (!prefixcmp(arg, -X))
+   else if (has_prefix(arg, -X))
return parse_dirstat_opt(options, arg + 2);
-   else if (!prefixcmp(arg, --dirstat=))
+   else if (has_prefix(arg, --dirstat

[PATCH 40/86] environment: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 environment.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/environment.c b/environment.c
index 378254c..827c6e8 100644
--- a/environment.c
+++ b/environment.c
@@ -176,7 +176,7 @@ const char *get_git_namespace(void)
 
 const char *strip_namespace(const char *namespaced_ref)
 {
-   if (prefixcmp(namespaced_ref, get_git_namespace()) != 0)
+   if (!has_prefix(namespaced_ref, get_git_namespace()))
return NULL;
return namespaced_ref + namespace_len;
 }
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 29/86] branch: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 branch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/branch.c b/branch.c
index 9e6c68e..fc3a61d 100644
--- a/branch.c
+++ b/branch.c
@@ -50,7 +50,7 @@ static int should_setup_rebase(const char *origin)
 void install_branch_config(int flag, const char *local, const char *origin, 
const char *remote)
 {
const char *shortname = remote + 11;
-   int remote_is_branch = !prefixcmp(remote, refs/heads/);
+   int remote_is_branch = has_prefix(remote, refs/heads/);
struct strbuf key = STRBUF_INIT;
int rebasing = should_setup_rebase(origin);
 
@@ -272,7 +272,7 @@ void create_branch(const char *head,
break;
case 1:
/* Unique completion -- good, only if it is a real branch */
-   if (prefixcmp(real_ref, refs/heads/) 
+   if (!has_prefix(real_ref, refs/heads/) 
validate_remote_tracking_branch(real_ref)) {
if (explicit_tracking)
die(_(upstream_not_branch), start_name);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 59/86] builtin/fsck: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/fsck.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/fsck.c b/builtin/fsck.c
index 97ce678..a80e51f 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -442,7 +442,7 @@ static void fsck_dir(int i, char *path)
add_sha1_list(sha1, DIRENT_SORT_HINT(de));
continue;
}
-   if (!prefixcmp(de-d_name, tmp_obj_))
+   if (has_prefix(de-d_name, tmp_obj_))
continue;
fprintf(stderr, bad sha1 file: %s/%s\n, path, de-d_name);
}
@@ -484,7 +484,7 @@ static int fsck_handle_reflog(const char *logname, const 
unsigned char *sha1, in
 
 static int is_branch(const char *refname)
 {
-   return !strcmp(refname, HEAD) || !prefixcmp(refname, refs/heads/);
+   return !strcmp(refname, HEAD) || has_prefix(refname, refs/heads/);
 }
 
 static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int 
flag, void *cb_data)
@@ -566,7 +566,7 @@ static int fsck_head_link(void)
if (!strcmp(head_points_at, HEAD))
/* detached HEAD */
null_is_error = 1;
-   else if (prefixcmp(head_points_at, refs/heads/))
+   else if (!has_prefix(head_points_at, refs/heads/))
return error(HEAD points to something strange (%s),
 head_points_at);
if (is_null_sha1(head_sha1)) {
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/86] sha1_name: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 sha1_name.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/sha1_name.c b/sha1_name.c
index 0e5fe7f..3224a39 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -547,7 +547,7 @@ static int get_sha1_basic(const char *str, int len, 
unsigned char *sha1)
if (read_ref_at(real_ref, at_time, nth, sha1, NULL,
co_time, co_tz, co_cnt)) {
if (!len) {
-   if (!prefixcmp(real_ref, refs/heads/)) {
+   if (has_prefix(real_ref, refs/heads/)) {
str = real_ref + 11;
len = strlen(real_ref + 11);
} else {
@@ -677,15 +677,15 @@ static int peel_onion(const char *name, int len, unsigned 
char *sha1)
return -1;
 
sp++; /* beginning of type name, or closing brace for empty */
-   if (!prefixcmp(sp, commit}))
+   if (has_prefix(sp, commit}))
expected_type = OBJ_COMMIT;
-   else if (!prefixcmp(sp, tag}))
+   else if (has_prefix(sp, tag}))
expected_type = OBJ_TAG;
-   else if (!prefixcmp(sp, tree}))
+   else if (has_prefix(sp, tree}))
expected_type = OBJ_TREE;
-   else if (!prefixcmp(sp, blob}))
+   else if (has_prefix(sp, blob}))
expected_type = OBJ_BLOB;
-   else if (!prefixcmp(sp, object}))
+   else if (has_prefix(sp, object}))
expected_type = OBJ_ANY;
else if (sp[0] == '}')
expected_type = OBJ_NONE;
@@ -912,7 +912,7 @@ static int grab_nth_branch_switch(unsigned char *osha1, 
unsigned char *nsha1,
const char *match = NULL, *target = NULL;
size_t len;
 
-   if (!prefixcmp(message, checkout: moving from )) {
+   if (has_prefix(message, checkout: moving from )) {
match = message + strlen(checkout: moving from );
target = strstr(match,  to );
}
@@ -1305,7 +1305,7 @@ static void diagnose_invalid_index_path(int stage,
 
 static char *resolve_relative_path(const char *rel)
 {
-   if (prefixcmp(rel, ./)  prefixcmp(rel, ../))
+   if (!has_prefix(rel, ./)  !has_prefix(rel, ../))
return NULL;
 
if (!startup_info)
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 11/86] wt-status: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 wt-status.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/wt-status.c b/wt-status.c
index b4e44ba..47806d1 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -803,7 +803,7 @@ static void wt_status_print_tracking(struct wt_status *s)
int i;
 
assert(s-branch  !s-is_initial);
-   if (prefixcmp(s-branch, refs/heads/))
+   if (!has_prefix(s-branch, refs/heads/))
return;
branch = branch_get(s-branch + 11);
if (!format_tracking_info(branch, sb))
@@ -1062,9 +1062,9 @@ static char *read_and_strip_branch(const char *path)
strbuf_setlen(sb, sb.len - 1);
if (!sb.len)
goto got_nothing;
-   if (!prefixcmp(sb.buf, refs/heads/))
+   if (has_prefix(sb.buf, refs/heads/))
strbuf_remove(sb,0, strlen(refs/heads/));
-   else if (!prefixcmp(sb.buf, refs/))
+   else if (has_prefix(sb.buf, refs/))
;
else if (!get_sha1_hex(sb.buf, sha1)) {
const char *abbrev;
@@ -1094,7 +1094,7 @@ static int grab_1st_switch(unsigned char *osha1, unsigned 
char *nsha1,
struct grab_1st_switch_cbdata *cb = cb_data;
const char *target = NULL, *end;
 
-   if (prefixcmp(message, checkout: moving from ))
+   if (!has_prefix(message, checkout: moving from ))
return 0;
message += strlen(checkout: moving from );
target = strstr(message,  to );
@@ -1129,9 +1129,9 @@ static void wt_status_get_detached_from(struct 
wt_status_state *state)
 ((commit = lookup_commit_reference_gently(sha1, 1)) != NULL 
  !hashcmp(cb.nsha1, commit-object.sha1 {
int ofs;
-   if (!prefixcmp(ref, refs/tags/))
+   if (has_prefix(ref, refs/tags/))
ofs = strlen(refs/tags/);
-   else if (!prefixcmp(ref, refs/remotes/))
+   else if (has_prefix(ref, refs/remotes/))
ofs = strlen(refs/remotes/);
else
ofs = 0;
@@ -1220,7 +1220,7 @@ void wt_status_print(struct wt_status *s)
if (s-branch) {
const char *on_what = _(On branch );
const char *branch_name = s-branch;
-   if (!prefixcmp(branch_name, refs/heads/))
+   if (has_prefix(branch_name, refs/heads/))
branch_name += 11;
else if (!strcmp(branch_name, HEAD)) {
branch_status_color = color(WT_STATUS_NOBRANCH, s);
@@ -1421,7 +1421,7 @@ static void wt_shortstatus_print_tracking(struct 
wt_status *s)
return;
branch_name = s-branch;
 
-   if (!prefixcmp(branch_name, refs/heads/))
+   if (has_prefix(branch_name, refs/heads/))
branch_name += 11;
else if (!strcmp(branch_name, HEAD)) {
branch_name = _(HEAD (no branch));
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 28/86] bisect: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 bisect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bisect.c b/bisect.c
index 1e46a4f..4819091 100644
--- a/bisect.c
+++ b/bisect.c
@@ -406,9 +406,9 @@ static int register_ref(const char *refname, const unsigned 
char *sha1,
if (!strcmp(refname, bad)) {
current_bad_sha1 = xmalloc(20);
hashcpy(current_bad_sha1, sha1);
-   } else if (!prefixcmp(refname, good-)) {
+   } else if (has_prefix(refname, good-)) {
sha1_array_append(good_revs, sha1);
-   } else if (!prefixcmp(refname, skip-)) {
+   } else if (has_prefix(refname, skip-)) {
sha1_array_append(skipped_revs, sha1);
}
 
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 48/86] builtin/checkout: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/checkout.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0f57397..7ce15dd 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -781,7 +781,7 @@ static int switch_branches(const struct checkout_opts *opts,
if (!(flag  REF_ISSYMREF))
old.path = NULL;
 
-   if (old.path  !prefixcmp(old.path, refs/heads/))
+   if (old.path  has_prefix(old.path, refs/heads/))
old.name = old.path + strlen(refs/heads/);
 
if (!new-name) {
@@ -816,7 +816,7 @@ static int git_checkout_config(const char *var, const char 
*value, void *cb)
return 0;
}
 
-   if (!prefixcmp(var, submodule.))
+   if (has_prefix(var, submodule.))
return parse_submodule_config_option(var, value);
 
return git_xmerge_config(var, value, NULL);
@@ -1108,9 +1108,9 @@ int cmd_checkout(int argc, const char **argv, const char 
*prefix)
const char *argv0 = argv[0];
if (!argc || !strcmp(argv0, --))
die (_(--track needs a branch name));
-   if (!prefixcmp(argv0, refs/))
+   if (has_prefix(argv0, refs/))
argv0 += 5;
-   if (!prefixcmp(argv0, remotes/))
+   if (has_prefix(argv0, remotes/))
argv0 += 8;
argv0 = strchr(argv0, '/');
if (!argv0 || !argv0[1])
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 39/86] convert: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 convert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/convert.c b/convert.c
index 11a95fc..dc5d3ed 100644
--- a/convert.c
+++ b/convert.c
@@ -1121,7 +1121,7 @@ static int is_foreign_ident(const char *str)
 {
int i;
 
-   if (prefixcmp(str, $Id: ))
+   if (!has_prefix(str, $Id: ))
return 0;
for (i = 5; str[i]; i++) {
if (isspace(str[i])  str[i+1] != '$')
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 45/86] builtin/apply: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/apply.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/apply.c b/builtin/apply.c
index ef32e4f..49028da 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1409,10 +1409,10 @@ static void recount_diff(const char *line, int size, 
struct fragment *fragment)
case '\\':
continue;
case '@':
-   ret = size  3 || prefixcmp(line, @@ );
+   ret = size  3 || !has_prefix(line, @@ );
break;
case 'd':
-   ret = size  5 || prefixcmp(line, diff );
+   ret = size  5 || !has_prefix(line, diff );
break;
default:
ret = -1;
@@ -1798,11 +1798,11 @@ static struct fragment *parse_binary_hunk(char **buf_p,
 
*status_p = 0;
 
-   if (!prefixcmp(buffer, delta )) {
+   if (has_prefix(buffer, delta )) {
patch_method = BINARY_DELTA_DEFLATED;
origlen = strtoul(buffer + 6, NULL, 10);
}
-   else if (!prefixcmp(buffer, literal )) {
+   else if (has_prefix(buffer, literal )) {
patch_method = BINARY_LITERAL_DEFLATED;
origlen = strtoul(buffer + 8, NULL, 10);
}
@@ -3627,12 +3627,12 @@ static int preimage_sha1_in_gitlink_patch(struct patch 
*p, unsigned char sha1[20
hunk-oldpos == 1  hunk-oldlines == 1 
/* does preimage begin with the heading? */
(preimage = memchr(hunk-patch, '\n', hunk-size)) != NULL 
-   !prefixcmp(++preimage, heading) 
+   has_prefix(++preimage, heading) 
/* does it record full SHA-1? */
!get_sha1_hex(preimage + sizeof(heading) - 1, sha1) 
preimage[sizeof(heading) + 40 - 1] == '\n' 
/* does the abbreviated name on the index line agree with it? */
-   !prefixcmp(preimage + sizeof(heading) - 1, p-old_sha1_prefix))
+   has_prefix(preimage + sizeof(heading) - 1, p-old_sha1_prefix))
return 0; /* it all looks fine */
 
/* we may have full object name on the index line */
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 13/86] test-line-buffer: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 test-line-buffer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/test-line-buffer.c b/test-line-buffer.c
index ef1d7ba..ed0d681 100644
--- a/test-line-buffer.c
+++ b/test-line-buffer.c
@@ -19,7 +19,7 @@ static void handle_command(const char *command, const char 
*arg, struct line_buf
 {
switch (*command) {
case 'b':
-   if (!prefixcmp(command, binary )) {
+   if (has_prefix(command, binary )) {
struct strbuf sb = STRBUF_INIT;
strbuf_addch(sb, '');
buffer_read_binary(buf, sb, strtouint32(arg));
@@ -28,12 +28,12 @@ static void handle_command(const char *command, const char 
*arg, struct line_buf
return;
}
case 'c':
-   if (!prefixcmp(command, copy )) {
+   if (has_prefix(command, copy )) {
buffer_copy_bytes(buf, strtouint32(arg));
return;
}
case 's':
-   if (!prefixcmp(command, skip )) {
+   if (has_prefix(command, skip )) {
buffer_skip_bytes(buf, strtouint32(arg));
return;
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 58/86] builtin/for-each-ref: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/for-each-ref.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 1d4083c..c22f200 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -432,7 +432,7 @@ static void grab_person(const char *who, struct atom_value 
*val, int deref, stru
if (name[wholen] != 0 
strcmp(name + wholen, name) 
strcmp(name + wholen, email) 
-   prefixcmp(name + wholen, date))
+   !has_prefix(name + wholen, date))
continue;
if (!wholine)
wholine = find_wholine(who, wholen, buf, sz);
@@ -444,7 +444,7 @@ static void grab_person(const char *who, struct atom_value 
*val, int deref, stru
v-s = copy_name(wholine);
else if (!strcmp(name + wholen, email))
v-s = copy_email(wholine);
-   else if (!prefixcmp(name + wholen, date))
+   else if (has_prefix(name + wholen, date))
grab_date(wholine, v, name);
}
 
@@ -466,7 +466,7 @@ static void grab_person(const char *who, struct atom_value 
*val, int deref, stru
if (deref)
name++;
 
-   if (!prefixcmp(name, creatordate))
+   if (has_prefix(name, creatordate))
grab_date(wholine, v, name);
else if (!strcmp(name, creator))
v-s = copy_line(wholine);
@@ -646,14 +646,14 @@ static void populate_value(struct refinfo *ref)
name++;
}
 
-   if (!prefixcmp(name, refname))
+   if (has_prefix(name, refname))
refname = ref-refname;
-   else if (!prefixcmp(name, symref))
+   else if (has_prefix(name, symref))
refname = ref-symref ? ref-symref : ;
-   else if (!prefixcmp(name, upstream)) {
+   else if (has_prefix(name, upstream)) {
struct branch *branch;
/* only local branches may have an upstream */
-   if (prefixcmp(ref-refname, refs/heads/))
+   if (!has_prefix(ref-refname, refs/heads/))
continue;
branch = branch_get(ref-refname + 11);
 
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/86] daemon: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 daemon.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/daemon.c b/daemon.c
index 34916c5..4b23800 100644
--- a/daemon.c
+++ b/daemon.c
@@ -235,7 +235,7 @@ static int service_enabled;
 
 static int git_daemon_config(const char *var, const char *value, void *cb)
 {
-   if (!prefixcmp(var, daemon.) 
+   if (has_prefix(var, daemon.) 
!strcmp(var + 7, service_looking_at-config_name)) {
service_enabled = git_config_bool(var, value);
return 0;
@@ -633,7 +633,7 @@ static int execute(void)
for (i = 0; i  ARRAY_SIZE(daemon_service); i++) {
struct daemon_service *s = (daemon_service[i]);
int namelen = strlen(s-name);
-   if (!prefixcmp(line, git-) 
+   if (has_prefix(line, git-) 
!strncmp(s-name, line + 4, namelen) 
line[namelen + 4] == ' ') {
/*
@@ -1165,11 +1165,11 @@ int main(int argc, char **argv)
for (i = 1; i  argc; i++) {
char *arg = argv[i];
 
-   if (!prefixcmp(arg, --listen=)) {
+   if (has_prefix(arg, --listen=)) {
string_list_append(listen_addr, xstrdup_tolower(arg + 
9));
continue;
}
-   if (!prefixcmp(arg, --port=)) {
+   if (has_prefix(arg, --port=)) {
char *end;
unsigned long n;
n = strtoul(arg+7, end, 0);
@@ -1199,19 +1199,19 @@ int main(int argc, char **argv)
export_all_trees = 1;
continue;
}
-   if (!prefixcmp(arg, --access-hook=)) {
+   if (has_prefix(arg, --access-hook=)) {
access_hook = arg + 14;
continue;
}
-   if (!prefixcmp(arg, --timeout=)) {
+   if (has_prefix(arg, --timeout=)) {
timeout = atoi(arg+10);
continue;
}
-   if (!prefixcmp(arg, --init-timeout=)) {
+   if (has_prefix(arg, --init-timeout=)) {
init_timeout = atoi(arg+15);
continue;
}
-   if (!prefixcmp(arg, --max-connections=)) {
+   if (has_prefix(arg, --max-connections=)) {
max_connections = atoi(arg+18);
if (max_connections  0)
max_connections = 0;/* unlimited */
@@ -1221,7 +1221,7 @@ int main(int argc, char **argv)
strict_paths = 1;
continue;
}
-   if (!prefixcmp(arg, --base-path=)) {
+   if (has_prefix(arg, --base-path=)) {
base_path = arg+12;
continue;
}
@@ -1229,7 +1229,7 @@ int main(int argc, char **argv)
base_path_relaxed = 1;
continue;
}
-   if (!prefixcmp(arg, --interpolated-path=)) {
+   if (has_prefix(arg, --interpolated-path=)) {
interpolated_path = arg+20;
continue;
}
@@ -1241,11 +1241,11 @@ int main(int argc, char **argv)
user_path = ;
continue;
}
-   if (!prefixcmp(arg, --user-path=)) {
+   if (has_prefix(arg, --user-path=)) {
user_path = arg + 12;
continue;
}
-   if (!prefixcmp(arg, --pid-file=)) {
+   if (has_prefix(arg, --pid-file=)) {
pid_file = arg + 11;
continue;
}
@@ -1254,35 +1254,35 @@ int main(int argc, char **argv)
log_syslog = 1;
continue;
}
-   if (!prefixcmp(arg, --user=)) {
+   if (has_prefix(arg, --user=)) {
user_name = arg + 7;
continue;
}
-   if (!prefixcmp(arg, --group=)) {
+   if (has_prefix(arg, --group=)) {
group_name = arg + 8;
continue;
}
-   if (!prefixcmp(arg, --enable=)) {
+   if (has_prefix(arg, --enable=)) {
enable_service(arg + 9, 1);
continue;
}
-   if (!prefixcmp(arg, --disable=)) {
+   if (has_prefix(arg, --disable=)) {
enable_service(arg + 10, 0);
continue;
}
-   if (!prefixcmp(arg

[PATCH 41/86] shell: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shell.c b/shell.c
index 66350b2..3bbe774 100644
--- a/shell.c
+++ b/shell.c
@@ -15,7 +15,7 @@ static int do_generic_cmd(const char *me, char *arg)
setup_path();
if (!arg || !(arg = sq_dequote(arg)))
die(bad argument);
-   if (prefixcmp(me, git-))
+   if (!has_prefix(me, git-))
die(bad command);
 
my_argv[0] = me + 4;
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 57/86] builtin/fmt-merge-msg: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/fmt-merge-msg.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 1c04070..09a55bf 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -109,7 +109,7 @@ static int handle_line(char *line, struct merge_parents 
*merge_parents)
if (len  43 || line[40] != '\t')
return 1;
 
-   if (!prefixcmp(line + 41, not-for-merge))
+   if (has_prefix(line + 41, not-for-merge))
return 0;
 
if (line[41] != '\t')
@@ -155,16 +155,16 @@ static int handle_line(char *line, struct merge_parents 
*merge_parents)
if (pulling_head) {
origin = src;
src_data-head_status |= 1;
-   } else if (!prefixcmp(line, branch )) {
+   } else if (has_prefix(line, branch )) {
origin_data-is_local_branch = 1;
origin = line + 7;
string_list_append(src_data-branch, origin);
src_data-head_status |= 2;
-   } else if (!prefixcmp(line, tag )) {
+   } else if (has_prefix(line, tag )) {
origin = line;
string_list_append(src_data-tag, origin + 4);
src_data-head_status |= 2;
-   } else if (!prefixcmp(line, remote-tracking branch )) {
+   } else if (has_prefix(line, remote-tracking branch )) {
origin = line + strlen(remote-tracking branch );
string_list_append(src_data-r_branch, origin);
src_data-head_status |= 2;
@@ -605,7 +605,7 @@ int fmt_merge_msg(struct strbuf *in, struct strbuf *out,
resolve_refdup(HEAD, head_sha1, 1, NULL);
if (!current_branch)
die(No current branch);
-   if (!prefixcmp(current_branch, refs/heads/))
+   if (has_prefix(current_branch, refs/heads/))
current_branch += 11;
 
find_merge_parents(merge_parents, in, head_sha1);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/86] config: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 config.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/config.c b/config.c
index e1d66a1..8d5d70c 100644
--- a/config.c
+++ b/config.c
@@ -969,25 +969,25 @@ static int git_default_mailmap_config(const char *var, 
const char *value)
 
 int git_default_config(const char *var, const char *value, void *dummy)
 {
-   if (!prefixcmp(var, core.))
+   if (has_prefix(var, core.))
return git_default_core_config(var, value);
 
-   if (!prefixcmp(var, user.))
+   if (has_prefix(var, user.))
return git_ident_config(var, value, dummy);
 
-   if (!prefixcmp(var, i18n.))
+   if (has_prefix(var, i18n.))
return git_default_i18n_config(var, value);
 
-   if (!prefixcmp(var, branch.))
+   if (has_prefix(var, branch.))
return git_default_branch_config(var, value);
 
-   if (!prefixcmp(var, push.))
+   if (has_prefix(var, push.))
return git_default_push_config(var, value);
 
-   if (!prefixcmp(var, mailmap.))
+   if (has_prefix(var, mailmap.))
return git_default_mailmap_config(var, value);
 
-   if (!prefixcmp(var, advice.))
+   if (has_prefix(var, advice.))
return git_default_advice_config(var, value);
 
if (!strcmp(var, pager.color) || !strcmp(var, color.pager)) {
@@ -1872,7 +1872,7 @@ int parse_config_key(const char *var,
const char *dot;
 
/* Does it start with section. ? */
-   if (prefixcmp(var, section) || var[section_len] != '.')
+   if (!has_prefix(var, section) || var[section_len] != '.')
return -1;
 
/*
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 56/86] builtin/fetch: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/fetch.c | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8eb6cd0..78d4add 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -313,7 +313,7 @@ static int update_local_ref(struct ref *ref,
}
 
if (!is_null_sha1(ref-old_sha1) 
-   !prefixcmp(ref-name, refs/tags/)) {
+   has_prefix(ref-name, refs/tags/)) {
int r;
r = s_update_ref(updating tag, ref, 0);
strbuf_addf(display, %c %-*s %-*s - %s%s,
@@ -336,10 +336,10 @@ static int update_local_ref(struct ref *ref,
 * more likely to follow a standard layout.
 */
const char *name = remote_ref ? remote_ref-name : ;
-   if (!prefixcmp(name, refs/tags/)) {
+   if (has_prefix(name, refs/tags/)) {
msg = storing tag;
what = _([new tag]);
-   } else if (!prefixcmp(name, refs/heads/)) {
+   } else if (has_prefix(name, refs/heads/)) {
msg = storing head;
what = _([new branch]);
} else {
@@ -471,15 +471,15 @@ static int store_updated_refs(const char *raw_url, const 
char *remote_name,
kind = ;
what = ;
}
-   else if (!prefixcmp(rm-name, refs/heads/)) {
+   else if (has_prefix(rm-name, refs/heads/)) {
kind = branch;
what = rm-name + 11;
}
-   else if (!prefixcmp(rm-name, refs/tags/)) {
+   else if (has_prefix(rm-name, refs/tags/)) {
kind = tag;
what = rm-name + 10;
}
-   else if (!prefixcmp(rm-name, refs/remotes/)) {
+   else if (has_prefix(rm-name, refs/remotes/)) {
kind = remote-tracking branch;
what = rm-name + 13;
}
@@ -644,7 +644,7 @@ static void find_non_local_tags(struct transport *transport,
 
for_each_ref(add_existing, existing_refs);
for (ref = transport_get_remote_refs(transport); ref; ref = ref-next) {
-   if (prefixcmp(ref-name, refs/tags/))
+   if (!has_prefix(ref-name, refs/tags/))
continue;
 
/*
@@ -892,7 +892,7 @@ static int get_remote_group(const char *key, const char 
*value, void *priv)
 {
struct remote_group_data *g = priv;
 
-   if (!prefixcmp(key, remotes.) 
+   if (has_prefix(key, remotes.) 
!strcmp(key + 8, g-name)) {
/* split list by white space */
int space = strcspn(value,  \t\n);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 37/86] connect: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 connect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/connect.c b/connect.c
index 4086861..1cb4090 100644
--- a/connect.c
+++ b/connect.c
@@ -87,7 +87,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t 
src_len,
if (!len)
break;
 
-   if (len  4  !prefixcmp(buffer, ERR ))
+   if (len  4  has_prefix(buffer, ERR ))
die(remote error: %s, buffer + 4);
 
if (len  42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != 
' ')
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/86] pretty: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 pretty.c | 36 ++--
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/pretty.c b/pretty.c
index b4e32b7..961241a 100644
--- a/pretty.c
+++ b/pretty.c
@@ -40,7 +40,7 @@ static int git_pretty_formats_config(const char *var, const 
char *value, void *c
const char *fmt;
int i;
 
-   if (prefixcmp(var, pretty.))
+   if (!has_prefix(var, pretty.))
return 0;
 
name = var + strlen(pretty.);
@@ -67,7 +67,7 @@ static int git_pretty_formats_config(const char *var, const 
char *value, void *c
commit_format-name = xstrdup(name);
commit_format-format = CMIT_FMT_USERFORMAT;
git_config_string(fmt, var, value);
-   if (!prefixcmp(fmt, format:) || !prefixcmp(fmt, tformat:)) {
+   if (has_prefix(fmt, format:) || has_prefix(fmt, tformat:)) {
commit_format-is_tformat = fmt[0] == 't';
fmt = strchr(fmt, ':') + 1;
} else if (strchr(fmt, '%'))
@@ -115,7 +115,7 @@ static struct cmt_fmt_map 
*find_commit_format_recursive(const char *sought,
for (i = 0; i  commit_formats_len; i++) {
size_t match_len;
 
-   if (prefixcmp(commit_formats[i].name, sought))
+   if (!has_prefix(commit_formats[i].name, sought))
continue;
 
match_len = strlen(commit_formats[i].name);
@@ -151,7 +151,7 @@ void get_commit_format(const char *arg, struct rev_info 
*rev)
rev-commit_format = CMIT_FMT_DEFAULT;
return;
}
-   if (!prefixcmp(arg, format:) || !prefixcmp(arg, tformat:)) {
+   if (has_prefix(arg, format:) || has_prefix(arg, tformat:)) {
save_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');
return;
}
@@ -840,10 +840,10 @@ static void parse_commit_header(struct 
format_commit_context *context)
 
if (i == eol) {
break;
-   } else if (!prefixcmp(msg + i, author )) {
+   } else if (has_prefix(msg + i, author )) {
context-author.off = i + 7;
context-author.len = eol - i - 7;
-   } else if (!prefixcmp(msg + i, committer )) {
+   } else if (has_prefix(msg + i, committer )) {
context-committer.off = i + 10;
context-committer.len = eol - i - 10;
}
@@ -983,7 +983,7 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 */
 
if (!end)
return 0;
-   if (!prefixcmp(begin, auto,)) {
+   if (has_prefix(begin, auto,)) {
if (!want_color(c-pretty_ctx-color))
return end - placeholder + 1;
begin += 5;
@@ -994,16 +994,16 @@ static size_t parse_color(struct strbuf *sb, /* in UTF-8 
*/
strbuf_addstr(sb, color);
return end - placeholder + 1;
}
-   if (!prefixcmp(placeholder + 1, red)) {
+   if (has_prefix(placeholder + 1, red)) {
strbuf_addstr(sb, GIT_COLOR_RED);
return 4;
-   } else if (!prefixcmp(placeholder + 1, green)) {
+   } else if (has_prefix(placeholder + 1, green)) {
strbuf_addstr(sb, GIT_COLOR_GREEN);
return 6;
-   } else if (!prefixcmp(placeholder + 1, blue)) {
+   } else if (has_prefix(placeholder + 1, blue)) {
strbuf_addstr(sb, GIT_COLOR_BLUE);
return 5;
-   } else if (!prefixcmp(placeholder + 1, reset)) {
+   } else if (has_prefix(placeholder + 1, reset)) {
strbuf_addstr(sb, GIT_COLOR_RESET);
return 6;
} else
@@ -1060,11 +1060,11 @@ static size_t parse_padding_placeholder(struct strbuf 
*sb,
end = strchr(start, ')');
if (!end || end == start)
return 0;
-   if (!prefixcmp(start, trunc)))
+   if (has_prefix(start, trunc)))
c-truncate = trunc_right;
-   else if (!prefixcmp(start, ltrunc)))
+   else if (has_prefix(start, ltrunc)))
c-truncate = trunc_left;
-   else if (!prefixcmp(start, mtrunc)))
+   else if (has_prefix(start, mtrunc)))
c-truncate = trunc_middle;
else
return 0;
@@ -1089,7 +1089,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in 
UTF-8 */
/* these are independent of the commit */
switch (placeholder[0]) {
case 'C':
-   if (!prefixcmp(placeholder + 1, (auto))) {
+   if (has_prefix(placeholder + 1, (auto

[PATCH 36/86] attr: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/attr.c b/attr.c
index 0e774c6..4c11f30 100644
--- a/attr.c
+++ b/attr.c
@@ -211,7 +211,7 @@ static struct match_attr *parse_attr_line(const char *line, 
const char *src,
name = cp;
namelen = strcspn(name, blank);
if (strlen(ATTRIBUTE_MACRO_PREFIX)  namelen 
-   !prefixcmp(name, ATTRIBUTE_MACRO_PREFIX)) {
+   has_prefix(name, ATTRIBUTE_MACRO_PREFIX)) {
if (!macro_ok) {
fprintf(stderr, %s not allowed: %s:%d\n,
name, src, lineno);
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 54/86] builtin/fast-export: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/fast-export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 78250ea..8a9136b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -476,7 +476,7 @@ static void handle_tag(const char *name, struct tag *tag)
}
}
 
-   if (!prefixcmp(name, refs/tags/))
+   if (has_prefix(name, refs/tags/))
name += 10;
printf(tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n,
   name, tagged_mark,
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 53/86] builtin/describe: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/describe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/builtin/describe.c b/builtin/describe.c
index b9d3603..102d958 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -141,7 +141,7 @@ static void add_to_known_names(const char *path,
 
 static int get_name(const char *path, const unsigned char *sha1, int flag, 
void *cb_data)
 {
-   int is_tag = !prefixcmp(path, refs/tags/);
+   int is_tag = has_prefix(path, refs/tags/);
unsigned char peeled[20];
int is_annotated, prio;
 
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 46/86] builtin/archive: replace prefixcmd() with has_prefix()

2013-11-08 Thread Christian Couder
Signed-off-by: Christian Couder chrisc...@tuxfamily.org
---
 builtin/archive.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin/archive.c b/builtin/archive.c
index 49178f1..b808bb5 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -57,9 +57,9 @@ static int run_remote_archiver(int argc, const char **argv,
if (!buf)
die(_(git archive: expected ACK/NAK, got EOF));
if (strcmp(buf, ACK)) {
-   if (!prefixcmp(buf, NACK ))
+   if (has_prefix(buf, NACK ))
die(_(git archive: NACK %s), buf + 5);
-   if (!prefixcmp(buf, ERR ))
+   if (has_prefix(buf, ERR ))
die(_(remote error: %s), buf + 4);
die(_(git archive: protocol error));
}
-- 
1.8.4.1.566.geca833c


--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2   3   4   5   6   7   8   9   10   >