Skip to content

Commit 0d4cd85

Browse files
author
Sylvain
committed
Minimalist LFS support (add relevant git lfs pull command at the end of subrepo pull and git lfs in temporary folder)
+ avoid --prune-empty when doing filter-branch to avoid later message about missing head commit when head is actually empty. Not related to LFS, just fixed because I hit it
1 parent 60b484d commit 0d4cd85

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

Meta

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=meta: 0.0.2
22

33
name: git-subrepo
4-
version: 0.4.1
4+
version: 0.4.2-lfs
55
abstract: Git Submodule Alternative
66
homepage: https://github.com/ingydotnet/git-subrepo#readme
77
license: MIT

lib/git-subrepo

+18-7
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ else
2828
fi
2929
bash+:import :std can
3030

31-
VERSION=0.4.1
31+
VERSION=0.4.2-LFS
3232
REQUIRED_GIT_VERSION=2.7.0
3333
GIT_TMP="$(git rev-parse --git-common-dir 2> /dev/null || echo .git)/tmp"
3434

@@ -572,9 +572,13 @@ subrepo:pull() {
572572

573573
o "Create ref '$refs_subrepo_branch' for branch '$branch_name'."
574574
git:make-ref "$refs_subrepo_branch" "$branch_name"
575-
575+
576576
o "Commit the new '$subrepo_commit_ref' content."
577577
CALL subrepo:commit
578+
579+
o "git lfs pull $subrepo_remote then commit"
580+
RUN git lfs pull "$subrepo_remote"
581+
RUN git commit -a --amend --allow-empty --no-edit
578582
}
579583

580584
# Push a properly merged subrepo branch upstream:
@@ -653,18 +657,17 @@ subrepo:push() {
653657
fi
654658

655659
if ! $force_wanted; then
656-
o "Make sure '$branch_name' contains the '$refs_subrepo_fetch' HEAD."
660+
o "Make sure '$branch_name' contains the '$refs_subrepo_fetch' HEAD, i.e. '$upstream_head_commit'."
657661
if ! git:commit-in-rev-list "$upstream_head_commit" "$branch_name"; then
658-
error "Can't commit: '$branch_name' doesn't contain upstream HEAD: " \
659-
"$upstream_head_commit"
662+
error "Can't commit: '$branch_name' doesn't contain upstream HEAD: '$upstream_head_commit'"
660663
fi
661664
fi
662665

663666
local force=''
664667
"$force_wanted" && force=' --force'
665668

666669
o "Push$force branch '$branch_name' to '$subrepo_remote' ($subrepo_branch)."
667-
RUN git push$force "$subrepo_remote" "$branch_name":"$subrepo_branch"
670+
RUN git push$force --no-verify "$subrepo_remote" "$branch_name":"$subrepo_branch"
668671

669672
o "Create ref '$refs_subrepo_push' for branch '$branch_name'."
670673
git:make-ref "$refs_subrepo_push" "$branch_name"
@@ -805,7 +808,7 @@ subrepo:branch() {
805808
o "Remove the .gitrepo file from $first_gitrepo_commit..$branch"
806809
local filter="$branch"
807810
[[ -n "$first_gitrepo_commit" ]] && filter="$first_gitrepo_commit..$branch"
808-
FAIL=false RUN git filter-branch -f --prune-empty --tree-filter \
811+
FAIL=false RUN git filter-branch -f --tree-filter \
809812
"rm -f .gitrepo" "$filter"
810813

811814
git:create-worktree "$branch"
@@ -1772,8 +1775,16 @@ git:is_merge_commit() {
17721775

17731776
git:create-worktree() {
17741777
local branch="$1"
1778+
local pwd=$(pwd)
17751779
worktree="$GIT_TMP/$branch"
1780+
o "git worktree add '$worktree' '$branch'"
17761781
RUN git worktree add "$worktree" "$branch"
1782+
1783+
cd "$worktree"
1784+
o "git lfs pull from folder '$(pwd)' then commit"
1785+
RUN git lfs pull
1786+
RUN git commit -a --amend --allow-empty --no-edit
1787+
cd "$pwd"
17771788
}
17781789

17791790
git:remove-worktree() {

0 commit comments

Comments
 (0)