The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

MrJobs (4) [Avatar] Offline
#1
Consider "Listing 6.5. git diff (between working area and staging area)" from the book.

diff --git a/math.sh b/math.sh
index 964c002..5bb7f63 100644
--- a/math.sh
+++ b/math.sh
@@ -1,4 +1,3 @@
# Comment
a=1
-echo $a
b=2

Does the following explain this line "@@ -1,4 +1,3 @@" correctly/roughly ?

The line starting with @@ is roughly saying take the original file/file in staging (a/math.sh) starting at the line 1 & going for 4 lines (-1,4). Then, apply the contents of the new file/file in working directory (b/math.sh) starting at line 1 & going for 3 lines (+1,3).
rickumali (134) [Avatar] Offline
#2
Hi MrJobs!

Yes, your description of the "@@" line looks accurate. I'm no expert on the hunk format, and when I considered your question, I found myself looking carefully at these resources:

1 https://www.gnu.org/software/diffutils/manual/html_node/Detailed-Unified.html
2 https://www.artima.com/weblogs/viewpost.jsp?thread=164293

Check these out. The second link is written by the author of Python!
612816 (1) [Avatar] Offline
#3
Hi,

And I think that the command description is wrong. git diff (with no option) is comparing your working area with the repository history. That is not correct. Sorry.
You can test that by adding the file to the staging area (git add) or by reverting the file to the original content (git check out). In both situations, the working area will have the same content as the last commit (right?)
So if after that you do git diff you will have no result.
Does that make sense for you?
Thank you.