-
Notifications
You must be signed in to change notification settings - Fork 0
/
handout_4a.txt
71 lines (56 loc) · 2.39 KB
/
handout_4a.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
CS 35L Software Construction Laboratory (Lab4-A)
Mon, April 23, 2012, Ver 1.2
Command "diff"
compare files line by line
diff helps you to find the difference between two files.
- Source code versioning
- Compare similar files
diff file_1 file_2
Note: without any option, diff will give you normal outut
a stands for added, d for deleted and c for changed
diff -u file_1 file_2
Note: with -u option, you will get unified format output
Programs using this format: patch, git, svn
Unified format output (header + hunk)
header: a diff file starts with two lines describe two files
--- test 2011-10-17 08:51:11.200077000 -0700
+++ test2 2011-10-17 08:51:30.086132000 -0700
hunk: a diff file contains one or more change hunks starting with
@@ -l,s +l,s @@
The first pair of l,s is for the origin file, and the second pair for
the new file. l indicates the start line number while s is the number of
lines in the hunk.
Diff Multiple files
$ diff <from-folder> <to-folder>
diff will autodetect the input is a file or a directory. And diff
each files in the directory
If you want to diff into subdirectories recursively, you may want to
use:
$ diff -r <from-folder> <to-folder>
More reading: http://en.wikipedia.org/wiki/Diff
Command "patch"
apply a diff file
usage:
1/ patch [options] [originalfile [patchfile]]
2/ patch -p0 <patchfile
-p option
-p option give patch the clue to figure out what is the filename to
patch on by indicating the number of "slashes" to ignore in the filenames
SEE: example1
Reverse a patch
$ patch -R < patchfile
Lab 4 Guideline
NOTE: Please start to work on the lab part only. Homework is subjest to
change.
In this lab, you need to create a patch using git and then apply it to a
previous version of the source code of diffutil
Software Version Control
Common features of Revision Control
1/ roll-back feature. (a snapshot of the source code)
2/ synchronization between team members
3/ source code distribution (e.g. github)
4/ quality assurance (QA) and code review
More reading: http://en.wikipedia.org/wiki/Revision_control
Two tools we will cover in Thursday: git and subversion (a.k.a. svn)
git http://en.wikipedia.org/wiki/Git_(software)
svn http://en.wikipedia.org/wiki/Apache_Subversion