Patchwork create-pull-request: Fix error on 2.0 versions of git

login
register
mail settings
Submitter Ben Shelton
Date Aug. 4, 2014, 6:55 p.m.
Message ID <1407178549-8464-1-git-send-email-ben.shelton@ni.com>
Download mbox | patch
Permalink /patch/77257/
State New
Headers show

Comments

Ben Shelton - Aug. 4, 2014, 6:55 p.m.
On 2.0 versions of git, the create-pull-request script exits with the
warning "No match for commit... Are you sure you pushed 'HEAD' there?".

This is due to a change in behavior where git used to guess the branch
you meant, but no longer does.  See the thread at
http://www.spinics.net/lists/git/msg233050.html for more information.

To accommodate the new behavior, if the COMMIT_ID is set to the default
of "HEAD", make it point explicitly to $BRANCH instead.

Signed-off-by: Ben Shelton <ben.shelton@ni.com>
---
 scripts/create-pull-request | 4 ++++
 1 file changed, 4 insertions(+)
Richard Tollerton - July 13, 2015, 6:43 p.m.
Ben Shelton <ben.shelton@ni.com> writes:

> On 2.0 versions of git, the create-pull-request script exits with the
> warning "No match for commit... Are you sure you pushed 'HEAD' there?".
>
> This is due to a change in behavior where git used to guess the branch
> you meant, but no longer does.  See the thread at
> http://www.spinics.net/lists/git/msg233050.html for more information.
>
> To accommodate the new behavior, if the COMMIT_ID is set to the default
> of "HEAD", make it point explicitly to $BRANCH instead.
>
> Signed-off-by: Ben Shelton <ben.shelton@ni.com>

I still need to apply this patch in order to use create-pull-request.
Bump?

> ---
>  scripts/create-pull-request | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/scripts/create-pull-request b/scripts/create-pull-request
> index 503248b..2bf5eb5 100755
> --- a/scripts/create-pull-request
> +++ b/scripts/create-pull-request
> @@ -125,6 +125,10 @@ if [ -z "$BRANCH" ]; then
>  	echo "NOTE: Assuming remote branch '$BRANCH', use -b to override."
>  fi
>  
> +if [ "$COMMIT_ID" == "HEAD" ]; then
> +	COMMIT_ID="$BRANCH"
> +fi
> +
>  if [ -z "$REMOTE_URL" ]; then
>  	echo "ERROR: Missing parameter -u, no git remote!"
>  	usage
> -- 
> 2.0.4
>
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core
Ross Burton - July 14, 2015, 9:49 a.m.
On 13 July 2015 at 19:43, Richard Tollerton <rich.tollerton@ni.com> wrote:

> Ben Shelton <ben.shelton@ni.com> writes:
>
> > On 2.0 versions of git, the create-pull-request script exits with the
> > warning "No match for commit... Are you sure you pushed 'HEAD' there?".
> >
> > This is due to a change in behavior where git used to guess the branch
> > you meant, but no longer does.  See the thread at
> > http://www.spinics.net/lists/git/msg233050.html for more information.
> >
> > To accommodate the new behavior, if the COMMIT_ID is set to the default
> > of "HEAD", make it point explicitly to $BRANCH instead.
> >
> > Signed-off-by: Ben Shelton <ben.shelton@ni.com>
>
> I still need to apply this patch in order to use create-pull-request.
> Bump?
>

Not sure how this got missed, and I can't even find it in my archives, but
it's queued now.

Ross
Robert Yang - July 17, 2015, 2:35 a.m.
On 07/14/2015 05:49 PM, Burton, Ross wrote:
>
> On 13 July 2015 at 19:43, Richard Tollerton <rich.tollerton@ni.com
> <mailto:rich.tollerton@ni.com>> wrote:
>
>     Ben Shelton <ben.shelton@ni.com <mailto:ben.shelton@ni.com>> writes:
>
>      > On 2.0 versions of git, the create-pull-request script exits with the
>      > warning "No match for commit... Are you sure you pushed 'HEAD' there?".
>      >
>      > This is due to a change in behavior where git used to guess the branch
>      > you meant, but no longer does.  See the thread at
>      > http://www.spinics.net/lists/git/msg233050.html for more information.
>      >
>      > To accommodate the new behavior, if the COMMIT_ID is set to the default
>      > of "HEAD", make it point explicitly to $BRANCH instead.
>      >
>      > Signed-off-by: Ben Shelton <ben.shelton@ni.com <mailto:ben.shelton@ni.com>>
>
>     I still need to apply this patch in order to use create-pull-request.
>     Bump?
>
>
> Not sure how this got missed, and I can't even find it in my archives, but it's
> queued now.

This patch breaks create-pull-request:
$ ./scripts/create-pull-request -u oe-contrib -b rbt/PU -r HEAD~5
fatal: ambiguous argument 'HEAD~5..rbt/PU': unknown revision or path not in the 
working tree.
Use '--' to separate paths from revisions
fatal: Needed a single revision
ERROR: git request-pull reported an error

$ git --version
git version 1.7.9.5


Richard Tollerton, does Saul's fix work for you for git 2.0?

commit 5ffa98a95317e6bea436e4372b9202f4da0ce2ae
Author: Saul Wold <sgw@linux.intel.com>
Date:   Tue Feb 3 09:08:29 2015 -0800

     create-pull-request: Fix git request-pull



// Robert

>
> Ross
>
>
Richard Tollerton - July 17, 2015, 4:39 p.m.
Robert Yang <liezhi.yang@windriver.com> writes:

> On 07/14/2015 05:49 PM, Burton, Ross wrote:
>>
>> On 13 July 2015 at 19:43, Richard Tollerton <rich.tollerton@ni.com
>> <mailto:rich.tollerton@ni.com>> wrote:
>>
>>     I still need to apply this patch in order to use create-pull-request.
>>     Bump?
>>
>> Not sure how this got missed, and I can't even find it in my archives, but it's
>> queued now.
>
> This patch breaks create-pull-request:
> $ ./scripts/create-pull-request -u oe-contrib -b rbt/PU -r HEAD~5
> fatal: ambiguous argument 'HEAD~5..rbt/PU': unknown revision or path not in the 
> working tree.
> Use '--' to separate paths from revisions
> fatal: Needed a single revision
> ERROR: git request-pull reported an error
>
> $ git --version
> git version 1.7.9.5
>
>
> Richard Tollerton, does Saul's fix work for you for git 2.0?
>
> commit 5ffa98a95317e6bea436e4372b9202f4da0ce2ae
> Author: Saul Wold <sgw@linux.intel.com>
> Date:   Tue Feb 3 09:08:29 2015 -0800
>
>      create-pull-request: Fix git request-pull

Eek! Yes, it seems like it does work. I think I might have
misinterpreted an error in running `create-pull-request`, then changed
the command line enough to (coincidentally) work after I reapplied the
patch.

Ross, please revert commit 7ee64ea60ede5477b2f9a355d93bdc556e6b7895. My
sincere apologies for the inconvenience.
Ross Burton - July 17, 2015, 4:50 p.m.
On 17 July 2015 at 17:39, Richard Tollerton <rich.tollerton@ni.com> wrote:

> Ross, please revert commit 7ee64ea60ede5477b2f9a355d93bdc556e6b7895. My
> sincere apologies for the inconvenience.
>

Already done in master-under-test.  Thanks for confirming that it works for
you.

Ross

Patch

diff --git a/scripts/create-pull-request b/scripts/create-pull-request
index 503248b..2bf5eb5 100755
--- a/scripts/create-pull-request
+++ b/scripts/create-pull-request
@@ -125,6 +125,10 @@  if [ -z "$BRANCH" ]; then
 	echo "NOTE: Assuming remote branch '$BRANCH', use -b to override."
 fi
 
+if [ "$COMMIT_ID" == "HEAD" ]; then
+	COMMIT_ID="$BRANCH"
+fi
+
 if [ -z "$REMOTE_URL" ]; then
 	echo "ERROR: Missing parameter -u, no git remote!"
 	usage