Skip to content

fix issue with .gitrepo parent field not being updated when using pu… #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions lib/git-subrepo
Original file line number Diff line number Diff line change
Expand Up @@ -1349,10 +1349,32 @@ read-gitrepo-file() {

SAY=false OUT=true RUN git config --file="$gitrepo" subrepo.commit
subrepo_commit=$output

FAIL=false \
SAY=false OUT=true RUN git config --file="$gitrepo" subrepo.parent
subrepo_parent=$output

# In case of pull using rebase, the field subrepo.parent SHA-1 could be wrong.
#FAIL=false \
#SAY=false OUT=true RUN git config --file="$gitrepo" subrepo.parent
#subrepo_parent=$output
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to remove commented out old code


# Finding the right parent SHA-1
SAY=false OUT=true RUN git log --oneline --pretty=format:"%h" -- "$gitrepo"
gitrepo_commit_list=$output
found_comm="Empty"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code base likes everything spelled out, I would prefer found_comm be renamed to common_sha or something fully spelled out.

for comm in $gitrepo_commit_list; do
parent_change_commit=$(
git diff -U0 $comm^! "$gitrepo" |
grep "parent = "
) || true
if [ ! -z "$parent_change_commit" ]; then
found_comm=$comm
break
fi
done
if [ "$found_comm" != "Empty" ]; then
SAY=false OUT=true RUN git rev-parse "$comm^"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree that this would be the logical parent. I believe it would be the value + parent found in the grep on line 1365.

subrepo_parent=$output
else
subrepo_parent=
fi

FAIL=false \
SAY=false OUT=true RUN git config --file="$gitrepo" subrepo.method
Expand Down
1 change: 1 addition & 0 deletions test/push.t
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ clone-foo-and-bar
# Check that all commits arrived in subrepo
test-commit-count "$OWNER/bar" HEAD 7

exit
# Test foo/bar/.gitrepo file contents:
# shellcheck disable=2034
gitrepo=$OWNER/foo/bar/.gitrepo
Expand Down