Re: [RFC] rebase: use @{upstream} if no upstream specified

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 13, 2010 at 4:51 AM, Yann Dirson <ydirson@xxxxxxx> wrote:
> On Fri, Nov 12, 2010 at 09:55:49PM +0100, Martin von Zweigbergk wrote:
>
>> @@ -21,6 +21,10 @@ If <branch> is specified, 'git rebase' will perform an automatic
>> Â`git checkout <branch>` before doing anything else. ÂOtherwise
>> Âit remains on the current branch.
>>
>> +If <upstream> is not specified, the upstream configured in
>> +branch.<name>.remote and branch.<name>.merge options will be used; see
>> +linkgit:git-config[1] for details.
>> +
>
> Maybe make explicit that it will abort when no upstream is configured.

Will do.

>
>> @@ -416,9 +409,31 @@ esac
>>
>> Âif test -z "$rebase_root"
>> Âthen
>> - Â Â # The upstream head must be given. ÂMake sure it is valid.
>> - Â Â upstream_name="$1"
>> - Â Â shift
>> + Â Â case "$#" in
>> + Â Â 0) Â Â Âbranch_name=$(git symbolic-ref -q HEAD) &&
>> + Â Â Â Â Â Â upstream_name=$(git for-each-ref \
>> + Â Â Â Â Â Â Â Â Â Â --format='%(upstream)' ${branch_name})
>> + Â Â Â Â Â Â if test -z $branch_name
>> + Â Â Â Â Â Â then
>> + Â Â Â Â Â Â Â Â Â Â die "You are not currently on a branch, so I cannot use any
>> +'branch.<branchname>.merge' in your configuration file.
>> +Please specify which upstream branch you want to use on the command
>> +line and try again (e.g. 'git rebase <upstream branch>').
>> +See git-rebase(1) for details."
>> + Â Â Â Â Â Â elif test -z $upstream_name
>> + Â Â Â Â Â Â then
>> + Â Â Â Â Â Â Â Â Â Â die "You asked me to rebase without telling me which branch you
>> +want to rebase against, and 'branch.${branch_name#refs/heads/}.merge' in
>> +your configuration file does not tell me, either. Please
>> +specify which branch you want to use on the command line and
>> +try again (e.g. 'git rebase <upstream branch>').
>> +See git-rebase(1) for details."
>> + Â Â Â Â Â Â fi
>> + Â Â Â Â Â Â ;;
>> + Â Â *) Â Â Âupstream_name="$1"
>> + Â Â Â Â Â Â shift
>> + Â Â Â Â Â Â ;;
>> + Â Â esac
>> Â Â Â upstream=`git rev-parse --verify "${upstream_name}^0"` ||
>> Â Â Â die "invalid upstream $upstream_name"
>> Â Â Â unset root_flag
>
> What about simply checking if "rev-parse @{u}" succeeds, in which case
> we can use upstream_name=@{u} ? ÂIf it fails, then we can do the work
> of finding where the config flaw is (and delegate this to a func).
> That would help keep the nominal code path short.

Will make sure to find out the error only when needed as you suggest.

I thought I would need the ref name to be able to walk the reflog if my
other propasal would be accepted (see
http://thread.gmane.org/gmane.comp.version-control.git/161381), but it
seems to work with @{u} as well. I just adapted the call from 'git pull'
(git-parse-remote.sh), but I guess I could use 'git rev-parse @{upstream}'
instead. It does seem more natural to me.

Maybe one of the guys on the CC list can advise?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]