https://cgi.cse.unsw.edu.au/~cs2041/24T1/assignments/ass1/index.html
Subset 2 原题
Subset 2 is extremely difficult. You will need to spend considerable time understanding the semantics of these operations, by running the reference implementation, and/or researching the equivalent Git operations.
Note the assessment scheme recognises this difficulty.
Subset 2 commands must be implemented in POSIX-compatible Shell.
See the Permitted Languages section for more information.
pushy-branch [-d] [branch-name]
pushy-branch
either creates a branch, deletes a branch, or lists current branch names.
If branch-name is omitted, the names of all branches are listed.
If branch-name is specified, then a branch with that name is created or deleted,
depending on whether the -d
option is specified.
pushy-checkout branch-name
pushy-checkout
switches branches.
Note that, unlike Git, you can not specify a commit or a file: you can only specify a branch.
pushy-merge (branch-name|commit-number) -m message
pushy-merge
adds the changes that have been made to the specified branch or commit to the index, and commits them.
Subset 2 examples
./pushy-init
Initialized empty pushy repository in .pushy
seq 1 7 >7.txt
./pushy-add 7.txt
./pushy-commit -m commit-1
Committed as commit 0
./pushy-branch b1
./pushy-checkout b1
Switched to branch 'b1'
sed -Ei 's/2/42/' 7.txt
cat 7.txt
1
42
3
4
5
6
7
./pushy-commit -a -m commit-2
Committed as commit 1
./pushy-checkout master
Switched to branch 'master'
cat 7.txt
1
2
3
4
5
6
7
./pushy-merge b1 -m merge-message
Fast-forward: no commit created
cat 7.txt
1
42
3
4
5
6
7
If a file has been changed in both branches pushy-merge