All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add -C[NUM] to git-am
@ 2007-02-07 20:15 Michael S. Tsirkin
  2007-02-07 20:23 ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2007-02-07 20:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git


Add -C[NUM] to git-am so that patches can be applied even
if context has changed a bit.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>

---

I just had to apply a largish number of patches on a project
that has evolved since, and I found the following to be useful.

What do others think.

diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index aa4ce1d..f7d551e 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -64,6 +64,10 @@ default.   You could use `--no-utf8` to override this.
 	This flag is passed to the `git-apply` program that applies
 	the patch.
 
+-C<n>::
+	This flag is passed to the `git-apply` program that applies
+	the patch.
+
 --interactive::
 	Run interactively, just like git-applymbox.
 
diff --git a/git-am.sh b/git-am.sh
index 1252f26..9a61234 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -3,7 +3,7 @@
 # Copyright (c) 2005, 2006 Junio C Hamano
 
 USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
-  [--interactive] [--whitespace=<option>] <mbox>...
+  [--interactive] [--whitespace=<option>] [-CNUM] <mbox>...
   or, when resuming [--skip | --resolved]'
 . git-sh-setup
 set_reflog_action am
@@ -106,7 +106,8 @@ It does not apply to blobs recorded in its index."
 }
 
 prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
+git_apply_opt=
 
 while case "$#" in 0) break;; esac
 do
@@ -142,7 +143,10 @@ do
 	skip=t; shift ;;
 
 	--whitespace=*)
-	ws=$1; shift ;;
+	git_apply_opt="$git_apply_opt $1"; shift ;;
+
+	-C*)
+	git_apply_opt="$git_apply_opt $1"; shift ;;
 
 	--resolvemsg=*)
 	resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
@@ -394,7 +398,7 @@ do
 
 	case "$resolved" in
 	'')
-		git-apply $binary --index $ws "$dotest/patch"
+		git-apply $git_apply_opt $binary --index "$dotest/patch"
 		apply_status=$?
 		;;
 	t)

-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 20:15 [PATCH] add -C[NUM] to git-am Michael S. Tsirkin
@ 2007-02-07 20:23 ` Junio C Hamano
  2007-02-07 21:19   ` Michael S. Tsirkin
  2007-02-07 23:50   ` Johannes Schindelin
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2007-02-07 20:23 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@mellanox.co.il> writes:

> Add -C[NUM] to git-am so that patches can be applied even
> if context has changed a bit.
>
> Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
>
> ---
>
> I just had to apply a largish number of patches on a project
> that has evolved since, and I found the following to be useful.
>
> What do others think.

FWIW, I am in favor although I do not foresee myself ever using
it.  However, this has slight ramifications.

 - we will be keeping applymbox after all.  shouldn't this be
   side-ported to it?

 - am is used as a workhorse for rebase.  shouldn't this be
   accessible through its command line as well?

The same goes for Andy's --patchdepth thing.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 20:23 ` Junio C Hamano
@ 2007-02-07 21:19   ` Michael S. Tsirkin
  2007-02-08  7:52     ` Junio C Hamano
  2007-02-07 23:50   ` Johannes Schindelin
  1 sibling, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2007-02-07 21:19 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Quoting r. Junio C Hamano <junkio@cox.net>:
> Subject: Re: [PATCH] add -C[NUM] to git-am
> 
> "Michael S. Tsirkin" <mst@mellanox.co.il> writes:
> 
> > Add -C[NUM] to git-am so that patches can be applied even
> > if context has changed a bit.
> >
> > Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>
> >
> > ---
> >
> > I just had to apply a largish number of patches on a project
> > that has evolved since, and I found the following to be useful.
> >
> > What do others think.
> 
> FWIW, I am in favor although I do not foresee myself ever using
> it.  However, this has slight ramifications.
> 
>  - we will be keeping applymbox after all.  shouldn't this be
>    side-ported to it?

OK.

>  - am is used as a workhorse for rebase.  shouldn't this be
>    accessible through its command line as well?

How will it be used?

-- 
MST

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 20:23 ` Junio C Hamano
  2007-02-07 21:19   ` Michael S. Tsirkin
@ 2007-02-07 23:50   ` Johannes Schindelin
  2007-02-07 23:54     ` Jakub Narebski
  1 sibling, 1 reply; 11+ messages in thread
From: Johannes Schindelin @ 2007-02-07 23:50 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Hi,

On Wed, 7 Feb 2007, Junio C Hamano wrote:

>  - we will be keeping applymbox after all.

Why? Does -am not do strictly more than applymbox?

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 23:50   ` Johannes Schindelin
@ 2007-02-07 23:54     ` Jakub Narebski
  2007-02-08  0:07       ` Johannes Schindelin
  0 siblings, 1 reply; 11+ messages in thread
From: Jakub Narebski @ 2007-02-07 23:54 UTC (permalink / raw)
  To: git

Johannes Schindelin wrote:
> On Wed, 7 Feb 2007, Junio C Hamano wrote:
> 
>>  - we will be keeping applymbox after all.
> 
> Why? Does -am not do strictly more than applymbox?

>From documentation, it looks like applymbox can get signoff from a file,
and am not.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 23:54     ` Jakub Narebski
@ 2007-02-08  0:07       ` Johannes Schindelin
  2007-02-08  0:17         ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Johannes Schindelin @ 2007-02-08  0:07 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Hi,

[please Cc me when replying]

On Thu, 8 Feb 2007, Jakub Narebski wrote:

> Johannes Schindelin wrote:
> > On Wed, 7 Feb 2007, Junio C Hamano wrote:
> > 
> >>  - we will be keeping applymbox after all.
> > 
> > Why? Does -am not do strictly more than applymbox?
> 
> From documentation, it looks like applymbox can get signoff from a file, 
> and am not.

Seems like just another low-hanging fruit. But I cannot believe that this 
is the only reason to keep applymbox.

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-08  0:07       ` Johannes Schindelin
@ 2007-02-08  0:17         ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2007-02-08  0:17 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Jakub Narebski

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> [please Cc me when replying]
>
> On Thu, 8 Feb 2007, Jakub Narebski wrote:
>
>> From documentation, it looks like applymbox can get signoff from a file, 
>> and am not.
>
> Seems like just another low-hanging fruit. But I cannot believe that this 
> is the only reason to keep applymbox.

I do not think <signoff> from file is of any practical use.  You
cannot feed your committer information to match from the same
file anyway.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-07 21:19   ` Michael S. Tsirkin
@ 2007-02-08  7:52     ` Junio C Hamano
  2007-02-08  8:35       ` Jakub Narebski
  2007-02-08 13:57       ` Michael S. Tsirkin
  0 siblings, 2 replies; 11+ messages in thread
From: Junio C Hamano @ 2007-02-08  7:52 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@mellanox.co.il> writes:

>> Quoting r. Junio C Hamano <junkio@cox.net>:
>> 
>> FWIW, I am in favor although I do not foresee myself ever using
>> it.  However, this has slight ramifications.
>> 
>>  - we will be keeping applymbox after all.  shouldn't this be
>>    side-ported to it?
>
> OK.
>
>>  - am is used as a workhorse for rebase.  shouldn't this be
>>    accessible through its command line as well?
>
> How will it be used?

Although I do not foresee myself using -C<num> that applies to
the whole series inexactly for "git am" to begin with, I would
imagine somebody who wants to say "git am -C1" may want to say
something like "git rebase -C1 origin/master",

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-08  7:52     ` Junio C Hamano
@ 2007-02-08  8:35       ` Jakub Narebski
  2007-02-08 13:57       ` Michael S. Tsirkin
  1 sibling, 0 replies; 11+ messages in thread
From: Jakub Narebski @ 2007-02-08  8:35 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> "Michael S. Tsirkin" <mst@mellanox.co.il> writes:
> 
>>> Quoting r. Junio C Hamano <junkio@cox.net>:
>>> 
>>> FWIW, I am in favor although I do not foresee myself ever using
>>> it.  However, this has slight ramifications.
>>> 
>>>  - we will be keeping applymbox after all.  shouldn't this be
>>>    side-ported to it?
>>
>> OK.
>>
>>>  - am is used as a workhorse for rebase.  shouldn't this be
>>>    accessible through its command line as well?
>>
>> How will it be used?
> 
> Although I do not foresee myself using -C<num> that applies to
> the whole series inexactly for "git am" to begin with, I would
> imagine somebody who wants to say "git am -C1" may want to say
> something like "git rebase -C1 origin/master",

What about "git rebase --merge"? 

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-08  7:52     ` Junio C Hamano
  2007-02-08  8:35       ` Jakub Narebski
@ 2007-02-08 13:57       ` Michael S. Tsirkin
  2007-02-08 23:04         ` Junio C Hamano
  1 sibling, 1 reply; 11+ messages in thread
From: Michael S. Tsirkin @ 2007-02-08 13:57 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

> Quoting Junio C Hamano <junkio@cox.net>:
> Subject: Re: [PATCH] add -C[NUM] to git-am
> 
> "Michael S. Tsirkin" <mst@mellanox.co.il> writes:
> 
> >> Quoting r. Junio C Hamano <junkio@cox.net>:
> >> 
> >> FWIW, I am in favor although I do not foresee myself ever using
> >> it.  However, this has slight ramifications.
> >> 
> >>  - we will be keeping applymbox after all.  shouldn't this be
> >>    side-ported to it?
> >
> > OK.

Wait, this can't be done - git-applymbox uses git-applypatch
internally and that does not get -CNUM.
So this will have to stay a git-am only option.

> >>  - am is used as a workhorse for rebase.  shouldn't this be
> >>    accessible through its command line as well?
> >
> > How will it be used?
> 
> Although I do not foresee myself using -C<num> that applies to
> the whole series inexactly for "git am" to begin with, I would
> imagine somebody who wants to say "git am -C1" may want to say
> something like "git rebase -C1 origin/master",

Like this then?
BTW, Junio, why is it that git-rebase calls "git am" and not "git-am"?
This wastes some cycles, does it not?


Add -C[NUM] to git-am and git-rebase so that patches can be applied even
if context has changed a bit.

Signed-off-by: Michael S. Tsirkin <mst@mellanox.co.il>

---

diff --git a/Documentation/git-am.txt b/Documentation/git-am.txt
index aa4ce1d..f7d551e 100644
--- a/Documentation/git-am.txt
+++ b/Documentation/git-am.txt
@@ -64,6 +64,10 @@ default.   You could use `--no-utf8` to override this.
 	This flag is passed to the `git-apply` program that applies
 	the patch.
 
+-C<n>::
+	This flag is passed to the `git-apply` program that applies
+	the patch.
+
 --interactive::
 	Run interactively, just like git-applymbox.
 
diff --git a/Documentation/git-rebase.txt b/Documentation/git-rebase.txt
index 977f661..3dff2df 100644
--- a/Documentation/git-rebase.txt
+++ b/Documentation/git-rebase.txt
@@ -7,7 +7,7 @@ git-rebase - Forward-port local commits to the updated upstream head
 
 SYNOPSIS
 --------
-'git-rebase' [-v] [--merge] [--onto <newbase>] <upstream> [<branch>]
+'git-rebase' [-v] [--merge] [-CNUM] [--onto <newbase>] <upstream> [<branch>]
 
 'git-rebase' --continue | --skip | --abort
 
@@ -196,6 +196,12 @@ OPTIONS
 -v, \--verbose::
 	Display a diffstat of what changed upstream since the last rebase.
 
+-C<n>::
+	Ensure at least <n> lines of surrounding context match before
+	and after each change.  When fewer lines of surrounding
+	context exist they all must match.  By default no context is
+	ever ignored.
+
 include::merge-strategies.txt[]
 
 NOTES
diff --git a/git-am.sh b/git-am.sh
index 1252f26..9a61234 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -3,7 +3,7 @@
 # Copyright (c) 2005, 2006 Junio C Hamano
 
 USAGE='[--signoff] [--dotest=<dir>] [--utf8 | --no-utf8] [--binary] [--3way]
-  [--interactive] [--whitespace=<option>] <mbox>...
+  [--interactive] [--whitespace=<option>] [-CNUM] <mbox>...
   or, when resuming [--skip | --resolved]'
 . git-sh-setup
 set_reflog_action am
@@ -106,7 +106,8 @@ It does not apply to blobs recorded in its index."
 }
 
 prec=4
-dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= ws= resolvemsg=
+dotest=.dotest sign= utf8=t keep= skip= interactive= resolved= binary= resolvemsg=
+git_apply_opt=
 
 while case "$#" in 0) break;; esac
 do
@@ -142,7 +143,10 @@ do
 	skip=t; shift ;;
 
 	--whitespace=*)
-	ws=$1; shift ;;
+	git_apply_opt="$git_apply_opt $1"; shift ;;
+
+	-C*)
+	git_apply_opt="$git_apply_opt $1"; shift ;;
 
 	--resolvemsg=*)
 	resolvemsg=$(echo "$1" | sed -e "s/^--resolvemsg=//"); shift ;;
@@ -394,7 +398,7 @@ do
 
 	case "$resolved" in
 	'')
-		git-apply $binary --index $ws "$dotest/patch"
+		git-apply $git_apply_opt $binary --index "$dotest/patch"
 		apply_status=$?
 		;;
 	t)
diff --git a/git-rebase.sh b/git-rebase.sh
index 9d2f71d..b51d19d 100755
--- a/git-rebase.sh
+++ b/git-rebase.sh
@@ -45,6 +45,7 @@ do_merge=
 dotest=$GIT_DIR/.dotest-merge
 prec=4
 verbose=
+git_am_opt=
 
 continue_merge () {
 	test -n "$prev_head" || die "prev_head must be defined"
@@ -213,6 +214,10 @@ do
 	-v|--verbose)
 		verbose=t
 		;;
+	-C*)
+		git_am_opt=$1
+		shift
+		;;
 	-*)
 		usage
 		;;
@@ -322,7 +327,7 @@ fi
 if test -z "$do_merge"
 then
 	git-format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
-	git am --binary -3 -k --resolvemsg="$RESOLVEMSG"
+	git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG"
 	exit $?
 fi
 
	
-- 
MST

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] add -C[NUM] to git-am
  2007-02-08 13:57       ` Michael S. Tsirkin
@ 2007-02-08 23:04         ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2007-02-08 23:04 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: git

"Michael S. Tsirkin" <mst@mellanox.co.il> writes:

> BTW, Junio, why is it that git-rebase calls "git am" and not "git-am"?

Not commenting on the patch itself yet in this message, but a
quick note on the above point.

At some point after 1.5.0 we might want to audit the scripts and
make sure we can still run with $(gitexecdir) set to somewhere
outside of the end user's $PATH.

In such a setting, an end user would start "git rebase" (or
whatever git program) because "git-rebase" will not be on her
$PATH.  The git wrapper would do the GIT_EXEC_PATH magic before
invoking "git-rebase", so even the call to "am" is made in
"git-am" form from our script, it will work correctly.

So in that sense, they are equivalent and does not matter from
correctness point of view. It used to matter cycle-wise because
the "git potty" was a shell script, but I do not think it
matters anymore.

Once we make sure we still correctly support $(gitexecdir) that
is different from $(bindir), we may want to update all the
invocation of "git foo" our scripts make to "git-foo", for a
different reason.

Once in-tree scripts and commands that invoke git stuff always
with git-foo syntax, I think we _could_ allow aliasing built-in
command with something else.  For example, we could allow
"[alias] foo = git-foo --my-favorite-flag" in the configuration
file and let the user say "git foo" from the command line to
mean "$GIT_EXEC_PATH/git-foo --my-favorite-flag", while not
affecting the uses of "git-foo" in *our* scripts.

I do not think we would want to change the default to use
separate bindir and gitexecdir, but the intent has always been
that we should make it easier to do if some distro wanted to 
package with gitexecdir set to /usr/libexec/git.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-02-08 23:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-07 20:15 [PATCH] add -C[NUM] to git-am Michael S. Tsirkin
2007-02-07 20:23 ` Junio C Hamano
2007-02-07 21:19   ` Michael S. Tsirkin
2007-02-08  7:52     ` Junio C Hamano
2007-02-08  8:35       ` Jakub Narebski
2007-02-08 13:57       ` Michael S. Tsirkin
2007-02-08 23:04         ` Junio C Hamano
2007-02-07 23:50   ` Johannes Schindelin
2007-02-07 23:54     ` Jakub Narebski
2007-02-08  0:07       ` Johannes Schindelin
2007-02-08  0:17         ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.