Skip to content

ads-github-merge-all-upstreams: chokes on "restoring previously checked-out branch" when it was a detached HEAD #21

@salewski

Description

@salewski

As you can see in the following (partial) transcript of the invocation:

    $ ads-github-merge-all-upstreams -vkp

from:

    $ ads-github-fetch-all-upstreams --version
    ads-github-fetch-all-upstreams 0.1.1  (built: 2016-09-27 17:49:46)
    Copyright (C) 2016 Alan D. Salewski
    License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>.
    This is free software: you are free to change and redistribute it.
    There is NO WARRANTY, to the extent permitted by law.

    Written by Alan D. Salewski.

the program choked when attempting to restore the checked-out branch to what
was checked-out prior to the program switching to the default branch. This
happened because the previously "checked-out branch" was actually a detached
head (the result of checking out a tag (the 'NET_2_0' tag in this example)):

    ads-github-merge-all-upstreams (info): [repo: "commons-net"] currently checked-out branch ("(detached from NET_2_0)") is NOT the default branch ("trunk"); checking out the default branch
    Previous HEAD position was 32c972d... Tag for release
    Switched to branch 'trunk'
    Your branch is up-to-date with 'origin/trunk'.
    Updating 2b0f338..cd29933
    Fast-forward
     src/changes/changes.xml                                                                   | 3 +++
     src/main/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactory.java     | 9 +++++----
     src/main/java/org/apache/commons/net/ftp/parser/UnixFTPEntryParser.java                   | 2 +-
     src/test/java/org/apache/commons/net/ftp/parser/DefaultFTPFileEntryParserFactoryTest.java | 5 +++++
     4 files changed, 14 insertions(+), 5 deletions(-)
    ads-github-merge-all-upstreams (info): [repo: "commons-net"] '-p' (--push) option specified; attempting to push default branch ("trunk") changes to origin
    Counting objects: 24, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (17/17), done.
    Writing objects: 100% (24/24), 3.14 KiB | 0 bytes/s, done.
    Total 24 (delta 8), reused 0 (delta 0)
    remote: Resolving deltas: 100% (8/8), completed with 8 local objects.
    To git@github.com:salewski/commons-net.git
       2b0f338..cd29933  trunk -> trunk
    ads-github-merge-all-upstreams (info): [repo: "commons-net"] restoring previously checked-out branch ("(detached from NET_2_0)")
    error: pathspec '(detached from NET_2_0)' did not match any file(s) known to git.
    ads-github-merge-all-upstreams (error): [repo: "commons-net"]: was unable to restore checkout of previously checked-ou branch ("(detached from NET_2_0)"); bailing out

The impact of the problem is just that the ads-github-merge-all-upstreams
program stops dead in its tracks and leave the repo directory with the default
branch checked out.

The workaround is to simply re-run the program leaving that repo with the
default branch checked out. Because the program will now find the repo with
the default branch checked out, it will not attempt to swicth the branch, so
will also not need to attempt to restore it to its original state. Once the
program has completed, the user can then manually check out the tag (or
whatever) to then put the repo back into the original state (if so desired).

The program should be modified to correctly deal with the scenario of a
detached head.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions