CRUX

Welcome to CRUX bug tracking.
Tasklist

FS#1794 - git driver: keep only the desired branch, prune and garbage collect useless objects

Attached to Project: CRUX
Opened by Steffen Nurpmeso (steffen) - Tuesday, 10 March 2020, 20:27 GMT
Last edited by Fredrik Rinnestam (frinnst) - Saturday, 05 September 2020, 00:43 GMT
Task Type Bug Report
Category ports
Status Closed
Assigned To Thomas Penteker (teK)
Operating System CRUX
Severity Medium
Priority Normal
Reported Version 3.5
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

How about this? In the normal case (without --aggressive) the cost is invisible in practice, even for elder boxes (which benefit the most from this change)

diff --git a/git/git b/git/git
index 654a8c770..51193dd2c 100644
--- a/git/git
+++ b/git/git
@@ -39,8 +39,15 @@ if [ $? -lt 1 ]; then
git diff --pretty=format: --name-status "$BRANCH" origin/"$BRANCH" | sed "s/M\t/ Edit /g; s/A\t/ Checkout /g; s/D\t/ Delete /g" | sort
git clean -q -f
git reset -q --hard origin/"$BRANCH"
+ i=`git branch | sed -e '/^*/d'`
+ if [ -n "$i" ]; then
+ git branch -q -d $i
+ i=--aggressive
+ fi
+ git gc --quiet $i --prune=all
else
- git clone -q -b "$BRANCH" "$URL" "$REPOSITORY"
+ git clone -q --single-branch -b "$BRANCH" "$URL" "$REPOSITORY"
+ git gc --quiet --aggressive --prune=all
ls -1 $REPOSITORY | sed "s/^/ Checkout /"
fi
This task depends upon

Closed by  Fredrik Rinnestam (frinnst)
Saturday, 05 September 2020, 00:43 GMT
Reason for closing:  Won't implement
Comment by Steffen Nurpmeso (steffen) - Friday, 04 September 2020, 20:30 GMT
Ah, forget about this mess, i close it. I use here, because need to fetch before checkout, right, and want some gc.


cd "$REPOSITORY" 2> "/dev/null"

if [ $? -eq 0 ]; then
git fetch -q
git checkout -q "$BRANCH"
git diff --pretty=format: --name-status "$BRANCH" origin/"$BRANCH" | sed "s/M\t/ Edit /g; s/A\t/ Checkout /g; s/D\t/ Delete /g" | sort
git clean -q -f -d
git reset -q --hard origin/"$BRANCH"
git gc --quiet $i --prune=all
else
git clone -q --single-branch -b "$BRANCH" "$URL" "$REPOSITORY"
git gc --quiet --aggressive --prune=all
ls -1 $REPOSITORY | sed "s/^/ Checkout /"
fi

Loading...