# [RFC] request-pull with diff body itself

5 messages from 2009-07-27 to 2009-07-28. Participants: Cyrill Gorcunov, Junio C Hamano.
Thread: https://gitlist.dev/t/20249

## Cyrill Gorcunov, 2009-07-27 19:53

Subject: [RFC] request-pull with diff body itself
Message-ID: <20090727195357.GE17942@lenovo>
URL: https://gitlist.dev/e/20090727195357.GE17942%40lenovo

```
Here is rfc in a sake of having ability to produce
diff body in small series of changes in request-pull.
we could use ">>" here and append diff by hands but
adding "-p" option seems more comfortable.

Dunno, just a thought.

Please CC me, I'm not subscribed.

	-- Cyrill
---
[RFC] request-pull -- produce long diff if needed

Allow git request-pull to append diff body into
pull request. It's really useful for small series
of commits.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---

This is just an RFC -- so if you don't like it feel
free to just drop. I found useful to have an ability
to pass additional "-p" option and have diff body in
request.

 git-request-pull.sh |   18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Index: git.git/git-request-pull.sh
=====================================================================
--- git.git.orig/git-request-pull.sh
+++ git.git/git-request-pull.sh
@@ -4,7 +4,7 @@
 # This file is licensed under the GPL v2, or a later version
 # at the discretion of Linus Torvalds.
 
-USAGE='<start> <url> [<end>]'
+USAGE='[-p] <start> <url> [<end>]'
 LONG_USAGE='Summarizes the changes between two commits to the standard output,
 and includes the given URL in the generated summary.'
 SUBDIRECTORY_OK='Yes'
@@ -15,6 +15,16 @@ OPTIONS_SPEC=
 GIT_PAGER=
 export GIT_PAGER
 
+usediff="no"
+if [ $# -eq 4 ]; then
+	if [ $1 = "-p" ]; then
+		usediff="yes"
+		shift
+	else
+		usage
+	fi
+fi
+
 base=$1
 url=$2
 head=${3-HEAD}
@@ -55,4 +65,10 @@ echo
 
 git shortlog ^$baserev $headrev
 git diff -M --stat --summary $merge_base $headrev
+
+if [ "$usediff" = "yes" ]; then
+	echo "---"
+	git diff -M -p $merge_base $headrev
+fi
+
 exit $status

```

## Junio C Hamano, 2009-07-27 20:46

Subject: Re: [RFC] request-pull with diff body itself
Message-ID: <7vws5tg8fw.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vws5tg8fw.fsf%40alter.siamese.dyndns.org
In-Reply-To: <20090727195357.GE17942@lenovo>

```
Cyrill Gorcunov <gorcunov@gmail.com> writes:

> Here is rfc in a sake of having ability to produce
> diff body in small series of changes in request-pull.
> we could use ">>" here and append diff by hands but
> adding "-p" option seems more comfortable.
>
> Dunno, just a thought.

I think this is a useful thing to add, as I think I've seen some
request-pull actually made with the patch text, most likely by hand.

>  git shortlog ^$baserev $headrev
>  git diff -M --stat --summary $merge_base $headrev
> +
> +if [ "$usediff" = "yes" ]; then
> +	echo "---"
> +	git diff -M -p $merge_base $headrev
> +fi

You can just use a single "git diff" invocation here,

	git diff -M --stat --summary $usediff $merge_base $headrev

and set up "$usediff" to be either empty or -p in the option parsing part.

```

## Cyrill Gorcunov, 2009-07-27 20:56

Subject: Re: [RFC] request-pull with diff body itself
Message-ID: <aa79d98a0907271356l51111uac0884cf148f434f@mail.gmail.com>
URL: https://gitlist.dev/e/aa79d98a0907271356l51111uac0884cf148f434f%40mail.gmail.com
In-Reply-To: <7vws5tg8fw.fsf@alter.siamese.dyndns.org>

```
On 7/28/09, Junio C Hamano <gitster@pobox.com> wrote:
> Cyrill Gorcunov <gorcunov@gmail.com> writes:
>
>> Here is rfc in a sake of having ability to produce
>> diff body in small series of changes in request-pull.
>> we could use ">>" here and append diff by hands but
>> adding "-p" option seems more comfortable.
>>
>> Dunno, just a thought.
>
> I think this is a useful thing to add, as I think I've seen some
> request-pull actually made with the patch text, most likely by hand.
>
>>  git shortlog ^$baserev $headrev
>>  git diff -M --stat --summary $merge_base $headrev
>> +
>> +if [ "$usediff" = "yes" ]; then
>> +	echo "---"
>> +	git diff -M -p $merge_base $headrev
>> +fi
>
> You can just use a single "git diff" invocation here,
>
> 	git diff -M --stat --summary $usediff $merge_base $headrev
>
> and set up "$usediff" to be either empty or -p in the option parsing part.
>
yeah, indeed, thanks for the hint Junio!
Will post an updated patch in a day or so ( as only get back my laptop
back). Or maybe someone could make it faster then me ;)

```

## Junio C Hamano, 2009-07-27 21:27

Subject: Re: [RFC] request-pull with diff body itself
Message-ID: <7vtz0xerzg.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtz0xerzg.fsf%40alter.siamese.dyndns.org
In-Reply-To: <aa79d98a0907271356l51111uac0884cf148f434f@mail.gmail.com>

```
Cyrill Gorcunov <gorcunov@gmail.com> writes:

> Will post an updated patch in a day or so ( as only get back my laptop
> back). Or maybe someone could make it faster then me ;)

Like this, perhaps.

 git-request-pull.sh |   24 ++++++++++++++++++++++--
 1 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 5917773..5c1121c 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -8,13 +8,33 @@ USAGE='<start> <url> [<end>]'
 LONG_USAGE='Summarizes the changes between two commits to the standard output,
 and includes the given URL in the generated summary.'
 SUBDIRECTORY_OK='Yes'
-OPTIONS_SPEC=
+OPTIONS_SPEC='git request-pull [options] start url [end]
+--
+p    show patch text as well
+'
+
 . git-sh-setup
 . git-parse-remote
 
 GIT_PAGER=
 export GIT_PAGER
 
+patch=
+while	case "$#" in 0) break ;; esac
+do
+	case "$1" in
+	-p)
+		patch=-p ;;
+	--)
+		shift; break ;;
+	-*)
+		usage ;;
+	*)
+		break ;;
+	esac
+	shift
+done
+
 base=$1
 url=$2
 head=${3-HEAD}
@@ -54,5 +74,5 @@ echo "  $url $branch"
 echo
 
 git shortlog ^$baserev $headrev
-git diff -M --stat --summary $merge_base $headrev
+git diff -M --stat --summary $patch $merge_base..$headrev
 exit $status

```

## Cyrill Gorcunov, 2009-07-28 06:00

Subject: Re: [RFC] request-pull with diff body itself
Message-ID: <20090728060008.GA4799@lenovo>
URL: https://gitlist.dev/e/20090728060008.GA4799%40lenovo
In-Reply-To: <7vtz0xerzg.fsf@alter.siamese.dyndns.org>

```
[Junio C Hamano - Mon, Jul 27, 2009 at 02:27:47PM -0700]
| Cyrill Gorcunov <gorcunov@gmail.com> writes:
| 
| > Will post an updated patch in a day or so ( as only get back my laptop
| > back). Or maybe someone could make it faster then me ;)
| 
| Like this, perhaps.
|
...

Yes, Junio, thanks! Please merge it into git repo
(if noone objects).

	-- Cyrill

```
