Skip to contentSkip to conversation

Improve can_hardlink diagnostics, remove suggest_hardlink

PATCH In review Pavel Roskin 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Improve can_hardlink diagnostics, remove suggest_hardlink

Hello!

suggest_hardlink is write-only in cg-pull - remove it. can_hardlink should not be shown to the user as is (it's either "l" or empty) - we should output something meaningful instead.

cg-pull +7 -4
@@ -207,7 +207,6 @@ fetch_local()
 	cp_flags_l="-vdpR"
 	if [ "$1" = "-u" ]; then
 		cp_flags_l="$cp_flags_l -fu$can_hardlink"
-		suggest_hardlink=
 		shift
 	fi
 
@@ -293,12 +292,16 @@ else
 	symlinked=
 	is_same_repo "$_git_objects" "$uri/objects" && symlinked=1
 
-	# See if we can hardlink and drop "l" if not.
+	# See if we can hardlink and add "-l" to cp flags.
 	can_hardlink=
 	sample_file=$(find $uri -type f -print | head -n 1)
 	rm -f $_git/.,,lntest
-	ln "$sample_file" "$_git/.,,lntest" 2>/dev/null && can_hardlink=l
-	echo $can_hardlink
+	if cp -fl "$sample_file" "$_git/.,,lntest" 2>/dev/null; then
+		can_hardlink=l
+		echo "Using hard links"
+	else
+		echo "Hard links don't work - using copy"
+	fi
 	rm -f $_git/.,,lntest
 fi
 
Signature · 2 lines
Regards,
Pavel Roskin
#1 lore raw

Dear diary, on Tue, Aug 23, 2005 at 06:23:58PM CEST, I got a letter where Pavel Roskin <[email protected]> told me that...

Quoted 1 line

Hello!

Hello,

Quoted 3 lines

suggest_hardlink is write-only in cg-pull - remove it. can_hardlink should not be shown to the user as is (it's either "l" or empty) - we should output something meaningful instead.

actually, the infamous "l" output was just a leftover debugging print I forgot to remove. ;-) Well, I guess it doesn't hurt if the user is notified whether hardlinking is done or not.

Signature · 4 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
If you want the holes in your knowledge showing up try teaching
someone.  -- Alan Cox