What does "@@ -1 +1 @@" mean in Git's diff output?

I've been collecting data from the information returned from

git diff <commitId>..<commitId>

and I ran into @@ -1 +1 @@

I can't figure out what that's telling me. I've searched a bit on Google but to no avail.

36178 次浏览

    It's the current hunk range information stating on which line numbers this diff hunk starts and ends.

  1. How should I save the time stamps in the database

At event creation, I would store UTC time and local time zone (aka creation time zone). I would use what I stored to convert UTC time into local time (aka creation time) and store it alongside UTC time and creation time zone.

Read http://en.wikipedia.org/wiki/Diff#Unified_format for an in-depth explanation.

NOTE: I can store local time from the get-go, but when the user does a search for an event, I would hope a conversion to local time exists. I also hope the server can detect which time zone the client is in.

    ode>) and store it alongside UTC time and creation time zone.

  1. How should I present them in the UI

NOTE: I can store local time from the get-go, but when the user does a search for an event, I would hope a conversion to local time exists. I also hope the server can detect which time zone the client is in.

  1. How should I present them in the UI

When a user searches for "9:00", I would search for events that include "9:00" in either UTC OR creation time OR local time. For the results, I would display one table of results in creation time (This is intended to display timestamps that may have been created in a different time zone, as we assume the user is looking for what time he created an event for wherever he was.), and display a second table of results below with related results, perhaps with the header, "Not what you're looking for? See related results" (these include the leftover UTC and local time results).

When a user searches for "9:00", I would search for events that include "9:00" in either UTC OR creation time OR local time. For the results, I would display one table of results in creation time (This is intended to display timestamps that may have been created in a different time zone, as we assume the user is looking for what time he created an event for wherever he was.), and display a second table of results below with related results, perhaps with the header, "Not what you're looking for? See related results" (these include the leftover UTC and local time results).

Overall, I would display UTC time, the local time, the creation time, and the creation time zone (i.e. the local time and time zone of the event where it was created) sorted by UTC time, so you can see which event comes first, in case two different events were scheduled for 9:00 in two different time zones.

Next come one or more hunks of differences; each hunk shows one area where the files differ. Unified format hunks look like this:

@@ from-file-line-numbers to-file-line-numbers @@
line-from-either-file
line-from-either-file...

Here I'm giving suggestions for best usability without bothering much about implementation feasibility.

If a hunk contains just one line, only its start line number appears. Otherwise its line numbers look like start,count. An empty hunk is considered to start at the line that follows the hunk.

1. For first issue of storing events in db, everybody would agree to store it in UTC

If a hunk and its context contain two or more lines, its line numbers look like start,count. Otherwise only its end line number appears. An empty hunk is considered to end at the line that precedes the hunk.

2. To give the best user experience, save the history of timezone of user. If you could save timestamp of time zone change, even better. This will enable us to give freedom to user to query without specifying timezone explicitly each time.

The lines common to both files begin with a space character. The lines that actually differ between the two files have one of the following indicator characters in the left print column:

    So with these features, let see how search query of just "9.00" by John will be handled:
    With above mentioned features, now I know

  • +
    that John has been in 2 timezones till date(or get timezones list for A line was added here to the first file.
  • mentioned period) . So I'll covert 9.00 from Sydney time zone to UTC, fire a query. Also convert 9.00 from NewYork time zone to UTC, fire a query. In result I'll show 2 rows to John displaying what he did at
  • -
    9.00 in sydney and at 9.00 in new york. New york line will be blank in this case, but I think still should be shown to user , just to inform A line was removed here from the first file.
him that we searched for this time zone too.

I would prefer that each team sees timestamp in its local time zone and other team's time zone. (I personally prefer to talk in timezone of person at other end for his convenience while scheduling a meeting). For more than 2 teams, its

3.What is a good way to ask the user for a timestamp that might include the time zone?

If his timezone is recently changed, whenever he logs in application, better to consider more common timezone i.e. UTC. So in this case, every user should see timestamp in 2 timezones, in UTC and in his default a notification should be given that, your default timezone is changed timezone.

to native timezone.
While creating event, lets say user selects

These suggestion are given with intention that user need not do any calculation in his local time but at the same he should be able communicate with other users fluently in their preferred time zone.

    Example: old file:

    func1() {
    1;
    2;
    3;
    4;
    5;
    6;
    7;
    8;
    9;
    }
    
  1. UTC. Keep it simple.

  2. If we remove line 6, the diff shows:

    @@ -4,7 +4,6 @@ func1() {
    3;
    4;
    5;
    -    6;
    7;
    8;
    9;
    

    Note that this is not the correct line for func1: it skipped lines 1 and 2.

    This awesome feature often tells exactly to which function or class each hunk belongs, which is very useful to interpret the diff.

    How the algorithm to choose the header works exactly is discussed at: Where does the excerpt in the git diff hunk header come from?